Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Commit

Permalink
Sample modifications; including argument checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
dajuric committed Oct 15, 2017
1 parent a919547 commit fafb830
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 8 deletions.
18 changes: 17 additions & 1 deletion Samples/ClientJs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,29 @@

namespace TestClientJs
{
/// <summary>
/// Remote API.
/// </summary>
interface IRemoteAPI
{
/// <summary>
/// Writes progress.
/// </summary>
/// <param name="progress">Progress value [0..1].</param>
void WriteProgress(float progress);
}

/// <summary>
/// Local API.
/// </summary>
class LocalAPI
{
/// <summary>
/// Executes long running addition task.
/// </summary>
/// <param name="a">First number.</param>
/// <param name="b">Second number.</param>
/// <returns>Result.</returns>
public async Task<int> LongRunningTask(int a, int b)
{
for (var p = 0; p <= 100; p += 5)
Expand All @@ -25,7 +41,7 @@ public async Task<int> LongRunningTask(int a, int b)
}
}

public class Program
class Program
{
//if access denied execute: "netsh http delete urlacl url=http://+:8001/"
//open Index.html to run the client
Expand Down
2 changes: 2 additions & 0 deletions Samples/ClientJs/ServerClientJs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>bin\ClientJs.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -31,6 +32,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<DocumentationFile>bin\ClientJs.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
Expand Down
2 changes: 2 additions & 0 deletions Samples/MultiService/MultiService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\ClientJsMultiService.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -29,6 +30,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\ClientJsMultiService.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
Expand Down
6 changes: 3 additions & 3 deletions Samples/MultiService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace ClientJsMultiService
/// <summary>
/// Numeric service providing operations on numbers.
/// </summary>
public class NumericService
class NumericService
{
/// <summary>
/// Adds two numbers.
Expand All @@ -25,7 +25,7 @@ public int Add(int a, int b)
/// <summary>
/// Text service providing operations on strings.
/// </summary>
public class TextService
class TextService
{
/// <summary>
/// Concatenates two strings.
Expand All @@ -39,7 +39,7 @@ public string Add(string a, string b)
}
}

public class Program
class Program
{
//if access denied execute: "netsh http delete urlacl url=http://+:8001/"
//open Index.html to run the client
Expand Down
2 changes: 1 addition & 1 deletion Samples/Serialization/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
/// <summary>
/// The image processing service API.
/// </summary>
public class ImageProcessingAPI
class ImageProcessingAPI
{
const int CHANNEL_COUNT = 3;

Expand Down
4 changes: 2 additions & 2 deletions Samples/ServerClientSample/Client/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

namespace TestClient
{
public interface ILocalAPI
interface ILocalAPI
{
Task<int> LongRunningTask(int a, int b);
}

public class RemoteAPI //:IRemoteAPI
class RemoteAPI //:IRemoteAPI
{
public void WriteProgress(float progress)
{
Expand Down
12 changes: 11 additions & 1 deletion Source/WebSocketRPC.JS/ClientAPIBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ function onMessage(msg, onError)
*/
this.connect = function (onOpen, onError, onClose)
{
if (!!onOpen === false || typeof onOpen !== 'function')
throw 'OnOpen function callback is missing.';

if (!!onError === false || typeof onError !== 'function')
throw 'OnError function callback is missing.';

if (!!onClose === false || typeof onClose !== 'function')
throw 'OnClose function callback is missing.';


if (!!window.WebSocket === false)
onError({ id: -1, title: "SOCKET_NOSUPPORT", summary: "This browser does not support Web sockets." });

Expand Down Expand Up @@ -146,7 +156,7 @@ this.onOtherMessage = null;
this.send = (msg) => ws.send(msg);

/*
* CLoses the underlying websocket connection.
* Closes the underlying websocket connection.
* @param {number} - Status code (see https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes for details).
* @param {string} - Human readable close reason (the max length is 123 bytes / ASCII characters).
*/
Expand Down

0 comments on commit fafb830

Please sign in to comment.