diff --git a/fonts/OpenSans-Bold-webfont.eot b/fonts/OpenSans-Bold-webfont.eot new file mode 100644 index 00000000..e1c76744 Binary files /dev/null and b/fonts/OpenSans-Bold-webfont.eot differ diff --git a/fonts/OpenSans-Bold-webfont.svg b/fonts/OpenSans-Bold-webfont.svg new file mode 100644 index 00000000..364b3686 --- /dev/null +++ b/fonts/OpenSans-Bold-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Bold-webfont.ttf b/fonts/OpenSans-Bold-webfont.ttf new file mode 100644 index 00000000..2d94f062 Binary files /dev/null and b/fonts/OpenSans-Bold-webfont.ttf differ diff --git a/fonts/OpenSans-Bold-webfont.woff b/fonts/OpenSans-Bold-webfont.woff new file mode 100644 index 00000000..cd86852d Binary files /dev/null and b/fonts/OpenSans-Bold-webfont.woff differ diff --git a/fonts/OpenSans-BoldItalic-webfont.eot b/fonts/OpenSans-BoldItalic-webfont.eot new file mode 100644 index 00000000..f44ac9a3 Binary files /dev/null and b/fonts/OpenSans-BoldItalic-webfont.eot differ diff --git a/fonts/OpenSans-BoldItalic-webfont.svg b/fonts/OpenSans-BoldItalic-webfont.svg new file mode 100644 index 00000000..8392240a --- /dev/null +++ b/fonts/OpenSans-BoldItalic-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-BoldItalic-webfont.ttf b/fonts/OpenSans-BoldItalic-webfont.ttf new file mode 100644 index 00000000..f74e0e3c Binary files /dev/null and b/fonts/OpenSans-BoldItalic-webfont.ttf differ diff --git a/fonts/OpenSans-BoldItalic-webfont.woff b/fonts/OpenSans-BoldItalic-webfont.woff new file mode 100644 index 00000000..f3248c11 Binary files /dev/null and b/fonts/OpenSans-BoldItalic-webfont.woff differ diff --git a/fonts/OpenSans-Italic-webfont.eot b/fonts/OpenSans-Italic-webfont.eot new file mode 100644 index 00000000..277c1899 Binary files /dev/null and b/fonts/OpenSans-Italic-webfont.eot differ diff --git a/fonts/OpenSans-Italic-webfont.svg b/fonts/OpenSans-Italic-webfont.svg new file mode 100644 index 00000000..29c7497f --- /dev/null +++ b/fonts/OpenSans-Italic-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Italic-webfont.ttf b/fonts/OpenSans-Italic-webfont.ttf new file mode 100644 index 00000000..63f187e9 Binary files /dev/null and b/fonts/OpenSans-Italic-webfont.ttf differ diff --git a/fonts/OpenSans-Italic-webfont.woff b/fonts/OpenSans-Italic-webfont.woff new file mode 100644 index 00000000..469a29bb Binary files /dev/null and b/fonts/OpenSans-Italic-webfont.woff differ diff --git a/fonts/OpenSans-Light-webfont.eot b/fonts/OpenSans-Light-webfont.eot new file mode 100644 index 00000000..837daab8 Binary files /dev/null and b/fonts/OpenSans-Light-webfont.eot differ diff --git a/fonts/OpenSans-Light-webfont.svg b/fonts/OpenSans-Light-webfont.svg new file mode 100644 index 00000000..bdb67265 --- /dev/null +++ b/fonts/OpenSans-Light-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Light-webfont.ttf b/fonts/OpenSans-Light-webfont.ttf new file mode 100644 index 00000000..b50ef9dc Binary files /dev/null and b/fonts/OpenSans-Light-webfont.ttf differ diff --git a/fonts/OpenSans-Light-webfont.woff b/fonts/OpenSans-Light-webfont.woff new file mode 100644 index 00000000..99514d1a Binary files /dev/null and b/fonts/OpenSans-Light-webfont.woff differ diff --git a/fonts/OpenSans-LightItalic-webfont.eot b/fonts/OpenSans-LightItalic-webfont.eot new file mode 100644 index 00000000..f0ebf2c0 Binary files /dev/null and b/fonts/OpenSans-LightItalic-webfont.eot differ diff --git a/fonts/OpenSans-LightItalic-webfont.svg b/fonts/OpenSans-LightItalic-webfont.svg new file mode 100644 index 00000000..60765da8 --- /dev/null +++ b/fonts/OpenSans-LightItalic-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-LightItalic-webfont.ttf b/fonts/OpenSans-LightItalic-webfont.ttf new file mode 100644 index 00000000..5898c8c7 Binary files /dev/null and b/fonts/OpenSans-LightItalic-webfont.ttf differ diff --git a/fonts/OpenSans-LightItalic-webfont.woff b/fonts/OpenSans-LightItalic-webfont.woff new file mode 100644 index 00000000..9c978dc3 Binary files /dev/null and b/fonts/OpenSans-LightItalic-webfont.woff differ diff --git a/fonts/OpenSans-Regular-webfont.eot b/fonts/OpenSans-Regular-webfont.eot new file mode 100644 index 00000000..dd6fd2cb Binary files /dev/null and b/fonts/OpenSans-Regular-webfont.eot differ diff --git a/fonts/OpenSans-Regular-webfont.svg b/fonts/OpenSans-Regular-webfont.svg new file mode 100644 index 00000000..01038bb1 --- /dev/null +++ b/fonts/OpenSans-Regular-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Regular-webfont.ttf b/fonts/OpenSans-Regular-webfont.ttf new file mode 100644 index 00000000..05951e7b Binary files /dev/null and b/fonts/OpenSans-Regular-webfont.ttf differ diff --git a/fonts/OpenSans-Regular-webfont.woff b/fonts/OpenSans-Regular-webfont.woff new file mode 100644 index 00000000..274664b2 Binary files /dev/null and b/fonts/OpenSans-Regular-webfont.woff differ diff --git a/fonts/OpenSans-Semibold-webfont.eot b/fonts/OpenSans-Semibold-webfont.eot new file mode 100644 index 00000000..289aade3 Binary files /dev/null and b/fonts/OpenSans-Semibold-webfont.eot differ diff --git a/fonts/OpenSans-Semibold-webfont.svg b/fonts/OpenSans-Semibold-webfont.svg new file mode 100644 index 00000000..cc2ca427 --- /dev/null +++ b/fonts/OpenSans-Semibold-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 2011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-Semibold-webfont.ttf b/fonts/OpenSans-Semibold-webfont.ttf new file mode 100644 index 00000000..6f150731 Binary files /dev/null and b/fonts/OpenSans-Semibold-webfont.ttf differ diff --git a/fonts/OpenSans-Semibold-webfont.woff b/fonts/OpenSans-Semibold-webfont.woff new file mode 100644 index 00000000..4e47cb1a Binary files /dev/null and b/fonts/OpenSans-Semibold-webfont.woff differ diff --git a/fonts/OpenSans-SemiboldItalic-webfont.eot b/fonts/OpenSans-SemiboldItalic-webfont.eot new file mode 100644 index 00000000..50a8a6f7 Binary files /dev/null and b/fonts/OpenSans-SemiboldItalic-webfont.eot differ diff --git a/fonts/OpenSans-SemiboldItalic-webfont.svg b/fonts/OpenSans-SemiboldItalic-webfont.svg new file mode 100644 index 00000000..65b50e2a --- /dev/null +++ b/fonts/OpenSans-SemiboldItalic-webfont.svg @@ -0,0 +1,146 @@ + + + + +This is a custom SVG webfont generated by Font Squirrel. +Copyright : Digitized data copyright 20102011 Google Corporation +Foundry : Ascender Corporation +Foundry URL : httpwwwascendercorpcom + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/fonts/OpenSans-SemiboldItalic-webfont.ttf b/fonts/OpenSans-SemiboldItalic-webfont.ttf new file mode 100644 index 00000000..55ba3120 Binary files /dev/null and b/fonts/OpenSans-SemiboldItalic-webfont.ttf differ diff --git a/fonts/OpenSans-SemiboldItalic-webfont.woff b/fonts/OpenSans-SemiboldItalic-webfont.woff new file mode 100644 index 00000000..0adc6df1 Binary files /dev/null and b/fonts/OpenSans-SemiboldItalic-webfont.woff differ diff --git a/images/bullet.png b/images/bullet.png new file mode 100644 index 00000000..22ea5437 Binary files /dev/null and b/images/bullet.png differ diff --git a/images/hr.gif b/images/hr.gif new file mode 100644 index 00000000..bdb4168d Binary files /dev/null and b/images/hr.gif differ diff --git a/images/nav-bg.gif b/images/nav-bg.gif new file mode 100644 index 00000000..47439656 Binary files /dev/null and b/images/nav-bg.gif differ diff --git a/index.html b/index.html index 3ca8542e..acab5832 100644 --- a/index.html +++ b/index.html @@ -4,29 +4,40 @@ websocket-sharp by sta - - + + + + - + +
-
-

websocket-sharp

-

A C# implementation of the WebSocket protocol client and server

-

View the Project on GitHub sta/websocket-sharp

- -
+
+
+

websocket-sharp

+

A C# implementation of the WebSocket protocol client and server

+
+ Project maintained by sta + Hosted on GitHub Pages — Theme by mattgraham +
+

Welcome to websocket-sharp!

@@ -41,13 +52,24 @@ Per-message Compression extension
  • Secure Connection
  • HTTP Authentication
  • +
  • Query String, Origin header and Cookies
  • .NET 3.5 or later (includes compatible)
  • +Branches

    + +

    Build

    websocket-sharp is built as a single assembly, websocket-sharp.dll.

    -

    websocket-sharp is developed with MonoDevelop. So the simple way to build is to open websocket-sharp.sln and run build for the websocket-sharp project with any of the build configurations (e.g. Debug) in the MonoDevelop.

    +

    websocket-sharp is developed with MonoDevelop. So the simple way to build is to open websocket-sharp.sln and run build for the websocket-sharp project with any of the build configurations (e.g. Debug) in the MonoDevelop.

    Install

    @@ -78,7 +100,17 @@

    It's priced at US$15. I think your $15 makes this project more better and accelerated, Thank you!

    +

    It works with Unity Free, but there are some limitations:

    + +

    Using .NET API 2.0 compatibility level for iOS/Android requires to fix lack of some features for later than .NET 2.0, such as the System.Func<...> delegates (i've fixed it in the asset package).

    + +

    And it's priced at US$15. I think your $15 makes this project more better and accelerated, Thank you!

    Usage

    @@ -159,18 +191,18 @@

    e has passed as a WebSocketSharp.MessageEventArgs.

    -

    e.Type property returns either WebSocketSharp.Opcode.TEXT or WebSocketSharp.Opcode.BINARY that represents the type of the received message. So by checking it, you determine which item you should use.

    +

    e.Type property returns either WebSocketSharp.Opcode.Text or WebSocketSharp.Opcode.Binary that represents the type of the received message. So by checking it, you determine which item you should use.

    -

    If e.Type is Opcode.TEXT, you should use e.Data property (returns a string) that represents the received Text message.

    +

    If e.Type is Opcode.Text, you should use e.Data property (returns a string) that represents the received Text message.

    -

    Or if e.Type is Opcode.BINARY, you should use e.RawData property (returns a byte []) that represents the received Binary message.

    +

    Or if e.Type is Opcode.Binary, you should use e.RawData property (returns a byte []) that represents the received Binary message.

    -
    if (e.Type == Opcode.TEXT) {
    +
    if (e.Type == Opcode.Text) {
       // Do something with e.Data
       return;
     }
     
    -if (e.Type == Opcode.BINARY) {
    +if (e.Type == Opcode.Binary) {
       // Do something with e.RawData
       return;
     }
    @@ -224,7 +256,7 @@
     
     

    The WebSocket.Send method is overloaded.

    -

    You can use the WebSocket.Send (string), WebSocket.Send (byte []), and WebSocket.Send (System.IO.FileInfo) methods to send a data.

    +

    You can use the WebSocket.Send (string), WebSocket.Send (byte []), or WebSocket.Send (System.IO.FileInfo) method to send a data.

    If you would like to send a data asynchronously, you should use the WebSocket.SendAsync method.

    @@ -263,8 +295,8 @@ protected override void OnMessage (MessageEventArgs e) { var msg = e.Data == "BALUS" - ? "I've been balused already..." - : "I'm not available now."; + ? "I've been balused already..." + : "I'm not available now."; Send (msg); } @@ -343,7 +375,7 @@

    If you override the WebSocketService.OnMessage (MessageEventArgs) method, it's called when the OnMessage event of the WebSocket used by the current session in the WebSocket service occurs.

    -

    And if you override the WebSocketService.OnOpen (), WebSocketService.OnError (ErrorEventArgs), and WebSocketService.OnClose (CloseEventArgs) methods, each of them is called when each event of the WebSocket (the OnOpen, OnError, and OnClose) occurs.

    +

    And if you override the WebSocketService.OnOpen (), WebSocketService.OnError (ErrorEventArgs), and WebSocketService.OnClose (CloseEventArgs) methods, each of them is called when each event of the WebSocket (the OnOpen, OnError, and OnClose events) occurs.

    The WebSocketService.Send method sends a data to the client on the current session in the WebSocket service.

    @@ -422,7 +454,7 @@

    If you would like to enable this extension as a WebSocket client, you should set like the following.

    -
    ws.Compression = CompressionMethod.DEFLATE;
    +
    ws.Compression = CompressionMethod.Deflate;
     

    And then your client sends the following header with the connection request to the server.

    @@ -491,6 +523,69 @@
    wssv.AuthenticationSchemes = AuthenticationSchemes.Digest;
     
    +

    +Query String, Origin header and Cookies

    + +

    As a WebSocket Client, if you would like to send the Query String with the WebSocket connection request to the server, you should create an instance of the WebSocket class with the WebSocket URL that includes the Query string parameters.

    + +
    using (var ws = new WebSocket ("ws://example.com/?name=nobita")) {
    +  ...
    +}
    +
    + +

    And if you would like to send the Origin header with the WebSocket connection request to the server, you should set the WebSocket.Origin property to an allowable value as the Origin header before connecting, like the following.

    + +
    ws.Origin = "http://example.com";
    +
    + +

    And if you would like to send the Cookies with the WebSocket connection request to the server, you should set any cookie using the WebSocket.SetCookie (WebSocketSharp.Net.Cookie) method before connecting, like the following.

    + +
    ws.SetCookie (new Cookie ("name", "nobita"));
    +
    + +

    As a WebSocket Server, if you would like to get the Query String included in each WebSocket connection request, you should access the WebSocketService.Context.QueryString property, like the following.

    + +
    public class Chat : WebSocketService
    +{
    +  private string _name;
    +
    +  ...
    +
    +  protected override void OnOpen ()
    +  {
    +    _name = Context.QueryString ["name"];
    +  }
    +
    +  ...
    +}
    +
    + +

    And if you would like to check the Origin header and Cookies included in each WebSocket connection request, you should set each validation for the Origin header and Cookies in your WebSocketService, for example, using the AddWebSocketService<T> (string, Func<T>) method with initializing, like the following.

    + +
    wssv.AddWebSocketService<Chat> (
    +  "/Chat",
    +  () => new Chat () {
    +    OriginValidator = value => {
    +      // Check 'value' of the Origin header, and return true if valid
    +      Uri origin;
    +      return !value.IsNullOrEmpty () &&
    +             Uri.TryCreate (value, UriKind.Absolute, out origin) &&
    +             origin.Host == "example.com";
    +    },
    +    CookiesValidator = (req, res) => {
    +      // Check the Cookies in 'req', and set the Cookies to send to the client with 'res' if necessary
    +      foreach (Cookie cookie in req) {
    +        cookie.Expired = true;
    +        res.Add (cookie);
    +      }
    +
    +      return true; // If valid
    +    }
    +  });
    +
    + +

    Also, if you would like to get each value of the Origin header and cookies, you should access each of the WebSocketService.Context.Origin and WebSocketService.Context.CookieCollection properties.

    +

    Logging

    @@ -498,14 +593,14 @@

    You can access it with the WebSocket.Log property (returns a WebSocketSharp.Logger).

    -

    So if you would like to change the current logging level (WebSocketSharp.LogLevel.ERROR as the default), you should set the WebSocket.Log.Level property to any of the LogLevel enum values.

    +

    So if you would like to change the current logging level (WebSocketSharp.LogLevel.Error as the default), you should set the WebSocket.Log.Level property to any of the LogLevel enum values.

    -
    ws.Log.Level = LogLevel.DEBUG;
    +
    ws.Log.Level = LogLevel.Debug;
     
    -

    This means a log with less than LogLevel.DEBUG cannot be outputted.

    +

    This means a log with lower than LogLevel.Debug cannot be outputted.

    -

    And if you would like to output a log, you should use any of the output methods. The following outputs a log with LogLevel.DEBUG.

    +

    And if you would like to output a log, you should use any of the output methods. The following outputs a log with LogLevel.Debug.

    ws.Log.Debug ("This is a debug message.");
     
    @@ -544,7 +639,7 @@

    Supported WebSocket Specifications

    -

    websocket-sharp supports RFC 6455 and is based on the following WebSocket references.

    +

    websocket-sharp supports RFC 6455, and it's based on the following WebSocket references:

    +
    -