2013-05-21 20:03:11 +08:00

2010-10-19 10:27:39 +08:00
2013-12-03 13:24:06 +08:00
## Welcome to websocket-sharp! ##
2013-12-01 13:19:04 +08:00
**websocket-sharp** supports the followings.
2013-11-30 00:41:30 +08:00
2013-12-03 13:24:06 +08:00
- **[WebSocket Client](#websocket-client)** and ** [Server ](#websocket-server )**
2013-11-30 00:57:02 +08:00
- **[RFC 6455](#supported-websocket-specifications)**
- **[Per-message Compression](#per-message-compression)** extension
2013-11-30 00:41:30 +08:00
- **[Secure Connection](#secure-connection)**
2013-12-01 13:19:04 +08:00
- .NET **3.5** or later (includes compatible)
2010-10-19 10:27:39 +08:00
2013-11-22 15:15:44 +08:00
## Branches ##
2013-11-30 00:41:30 +08:00
- **[master]** for production releases.
- **[hybi-00]** for older [draft-ietf-hybi-thewebsocketprotocol-00]. No longer maintained.
- **[draft75]** for even more old [draft-hixie-thewebsocketprotocol-75]. No longer maintained.
2013-11-22 15:15:44 +08:00
2013-11-17 16:03:52 +08:00
## Build ##
**websocket-sharp** is built as a single assembly, **websocket-sharp.dll** .
2013-11-18 02:38:54 +08:00
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.
2013-11-17 16:03:52 +08:00
2013-11-17 17:10:21 +08:00
## Install ##
### Self Build ###
2014-01-01 21:09:41 +08:00
You should add **websocket-sharp.dll** (e.g. /path/to/websocket-sharp/bin/Debug/websocket-sharp.dll) built yourself to the library references of your project.
2013-11-17 17:10:21 +08:00
2014-01-01 21:09:41 +08:00
If you use that websocket-sharp.dll in your ** [Unity]** project, you should add it to any folder of your project (e.g. Assets/Plugins) in the **Unity Editor** .
2013-11-18 03:59:29 +08:00
2013-11-17 17:10:21 +08:00
### NuGet Gallery ###
2014-01-01 21:09:41 +08:00
**websocket-sharp** is available on the ** [NuGet Gallery]**, as still a **prerelease** version.
2013-11-17 17:10:21 +08:00
- **[NuGet Gallery: websocket-sharp]**
2013-11-22 15:15:44 +08:00
You can add websocket-sharp to your project using the **NuGet Package Manager** , the following command in the **Package Manager Console** .
2013-11-17 17:10:21 +08:00
2013-11-22 20:11:19 +08:00
PM> Install-Package WebSocketSharp -Pre
2013-11-17 17:10:21 +08:00
### Unity Asset Store ###
2014-01-01 21:09:41 +08:00
**websocket-sharp** is available on the **Unity Asset Store** .
2013-11-17 17:10:21 +08:00
- **[websocket-sharp for Unity]**
2013-12-01 13:19:04 +08:00
It's priced at **US$15** . I think your $15 makes this project more better and accelerated, **Thank you!**
2013-11-17 17:10:21 +08:00
2010-10-19 10:27:39 +08:00
## Usage ##
2013-07-01 11:18:26 +08:00
### WebSocket Client ###
2012-08-04 14:51:31 +08:00
2013-04-12 23:41:04 +08:00
```cs
using System;
using WebSocketSharp;
2013-07-30 15:32:21 +08:00
namespace Example
{
public class Program
{
public static void Main (string [] args)
2013-04-12 23:41:04 +08:00
{
2014-01-01 21:09:41 +08:00
using (var ws = new WebSocket ("ws://dragonsnest.far/Laputa")) {
ws.OnMessage += (sender, e) => {
2013-11-15 21:11:21 +08:00
Console.WriteLine ("Laputa says: " + e.Data);
2013-04-12 23:41:04 +08:00
};
2013-07-30 15:32:21 +08:00
ws.Connect ();
ws.Send ("BALUS");
Console.ReadKey (true);
2013-04-12 23:41:04 +08:00
}
}
}
}
```
2012-08-04 14:51:31 +08:00
#### Step 1 ####
2010-10-19 10:27:39 +08:00
2013-01-28 15:22:24 +08:00
Required namespace.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
using WebSocketSharp;
```
2012-07-31 09:36:52 +08:00
2013-01-15 14:29:05 +08:00
The `WebSocket` class exists in the `WebSocketSharp` namespace.
2012-07-31 09:36:52 +08:00
2012-08-04 14:51:31 +08:00
#### Step 2 ####
2012-07-31 09:36:52 +08:00
2013-10-02 13:39:56 +08:00
Creating an instance of the `WebSocket` class with the specified WebSocket URL to connect.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2014-01-01 21:09:41 +08:00
using (var ws = new WebSocket ("ws://example.com")) {
2012-08-08 10:32:19 +08:00
...
}
```
2012-07-31 09:36:52 +08:00
2012-10-12 13:53:29 +08:00
The `WebSocket` class inherits the `IDisposable` interface, so you can use the `using` statement.
2012-07-31 09:36:52 +08:00
2012-08-04 14:51:31 +08:00
#### Step 3 ####
2012-07-31 09:36:52 +08:00
2012-10-12 13:53:29 +08:00
Setting the `WebSocket` events.
2012-07-31 09:36:52 +08:00
2013-07-24 22:05:33 +08:00
##### WebSocket.OnOpen Event #####
2012-07-31 09:36:52 +08:00
2013-07-15 19:42:55 +08:00
A `WebSocket.OnOpen` event occurs when the WebSocket connection has been established.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2014-01-01 21:09:41 +08:00
ws.OnOpen += (sender, e) => {
2012-08-08 10:32:19 +08:00
...
};
```
2012-07-31 09:36:52 +08:00
2013-11-15 21:11:21 +08:00
`e` has passed as `EventArgs.Empty` , so you don't use `e` .
2012-07-31 09:36:52 +08:00
2013-07-24 22:05:33 +08:00
##### WebSocket.OnMessage Event #####
2012-07-31 09:36:52 +08:00
2013-07-15 19:42:55 +08:00
A `WebSocket.OnMessage` event occurs when the `WebSocket` receives a WebSocket data frame.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2014-01-01 21:09:41 +08:00
ws.OnMessage += (sender, e) => {
2012-08-08 10:32:19 +08:00
...
};
```
2012-07-31 09:36:52 +08:00
2013-11-15 21:11:21 +08:00
`e.Type` (`WebSocketSharp.MessageEventArgs.Type`, its type is `WebSocketSharp.Opcode` ) indicates the type of a received data. So by checking it, you determine which item you should use.
2013-07-19 16:29:58 +08:00
2013-07-30 15:32:21 +08:00
If `e.Type` equals `Opcode.TEXT` , you use `e.Data` (`WebSocketSharp.MessageEventArgs.Data`, its type is `string` ) that contains a received **Text** data.
2013-07-19 16:29:58 +08:00
2013-07-30 15:32:21 +08:00
If `e.Type` equals `Opcode.BINARY` , you use `e.RawData` (`WebSocketSharp.MessageEventArgs.RawData`, its type is `byte []` ) that contains a received **Binary** data.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2014-01-01 21:09:41 +08:00
if (e.Type == Opcode.TEXT) {
2013-07-15 19:42:55 +08:00
// Do something with e.Data
return;
}
2014-01-01 21:09:41 +08:00
if (e.Type == Opcode.BINARY) {
2013-07-15 19:42:55 +08:00
// Do something with e.RawData
return;
2012-08-08 10:36:17 +08:00
}
2012-08-08 10:32:19 +08:00
```
2012-07-31 09:36:52 +08:00
2013-07-24 22:05:33 +08:00
##### WebSocket.OnError Event #####
2012-07-31 09:36:52 +08:00
2013-07-15 19:42:55 +08:00
A `WebSocket.OnError` event occurs when the `WebSocket` gets an error.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2014-01-01 21:09:41 +08:00
ws.OnError += (sender, e) => {
2012-08-08 10:32:19 +08:00
...
};
```
2013-11-22 20:11:19 +08:00
2013-07-30 15:32:21 +08:00
`e.Message` (`WebSocketSharp.ErrorEventArgs.Message`, its type is `string` ) contains an error message, so you use it.
2012-07-31 09:36:52 +08:00
2013-07-24 22:05:33 +08:00
##### WebSocket.OnClose Event #####
2012-07-31 09:36:52 +08:00
2013-07-15 19:42:55 +08:00
A `WebSocket.OnClose` event occurs when the WebSocket connection has been closed.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2014-01-01 21:09:41 +08:00
ws.OnClose += (sender, e) => {
2012-08-08 10:32:19 +08:00
...
};
```
2012-07-31 09:36:52 +08:00
2013-07-30 15:32:21 +08:00
`e.Code` (`WebSocketSharp.CloseEventArgs.Code`, its type is `ushort` ) contains a status code indicating the reason for closure and `e.Reason` (`WebSocketSharp.CloseEventArgs.Reason`, its type is `string` ) contains the reason for closure, so you use them.
2012-07-31 09:36:52 +08:00
2012-08-04 14:51:31 +08:00
#### Step 4 ####
2012-07-31 09:36:52 +08:00
2012-10-12 13:53:29 +08:00
Connecting to the WebSocket server.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2013-07-30 15:32:21 +08:00
ws.Connect ();
2012-08-08 10:32:19 +08:00
```
2012-07-31 09:36:52 +08:00
2012-08-04 14:51:31 +08:00
#### Step 5 ####
2012-07-31 09:36:52 +08:00
2012-10-12 13:53:29 +08:00
Sending a data.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2013-07-30 15:32:21 +08:00
ws.Send (data);
2012-08-08 10:32:19 +08:00
```
2012-07-31 09:36:52 +08:00
2013-11-22 20:11:19 +08:00
The `WebSocket.Send` method is overloaded.
2012-07-31 09:36:52 +08:00
2013-11-22 20:32:06 +08:00
The types of `data` are `string` , `byte []` and `System.IO.FileInfo` .
2013-10-15 23:18:05 +08:00
2013-11-22 20:11:19 +08:00
In addition, the `WebSocket.Send (stream, length)` method exists, too.
2013-10-15 23:18:05 +08:00
2013-12-03 13:24:06 +08:00
These methods don't wait for the send to be complete. It means these methods behave asynchronously.
2013-10-15 23:18:05 +08:00
2013-11-22 20:11:19 +08:00
If you do something when the send is complete, you use any of some `WebSocket.Send (data, completed)` methods.
2012-07-31 09:36:52 +08:00
2012-08-04 14:51:31 +08:00
#### Step 6 ####
2012-07-31 09:36:52 +08:00
2012-10-12 13:53:29 +08:00
Closing the WebSocket connection.
2012-07-31 09:36:52 +08:00
2012-08-08 10:32:19 +08:00
```cs
2013-07-30 15:32:21 +08:00
ws.Close (code, reason);
2012-08-08 10:32:19 +08:00
```
2012-07-31 09:36:52 +08:00
2013-12-03 13:24:06 +08:00
If you explicitly close the WebSocket connection, you use the `WebSocket.Close` method.
2012-07-31 09:36:52 +08:00
2013-11-22 20:11:19 +08:00
The `WebSocket.Close` method is overloaded.
2013-10-15 23:18:05 +08:00
The types of `code` are `WebSocketSharp.CloseStatusCode` and `ushort` , and the type of `reason` is `string` .
2012-07-31 09:36:52 +08:00
2013-11-22 20:11:19 +08:00
In addition, the `WebSocket.Close ()` and `WebSocket.Close (code)` methods exist, too.
2012-10-16 19:31:50 +08:00
2013-07-01 11:18:26 +08:00
### WebSocket Server ###
2012-08-04 14:51:31 +08:00
2013-04-12 23:41:04 +08:00
```cs
using System;
using WebSocketSharp;
using WebSocketSharp.Server;
2013-07-30 15:32:21 +08:00
namespace Example
{
2013-04-12 23:41:04 +08:00
public class Laputa : WebSocketService
{
2013-07-30 15:32:21 +08:00
protected override void OnMessage (MessageEventArgs e)
2013-04-12 23:41:04 +08:00
{
2013-11-18 02:17:18 +08:00
var msg = e.Data == "BALUS"
2013-04-12 23:41:04 +08:00
? "I've been balused already..."
: "I'm not available now.";
2013-11-05 20:55:16 +08:00
2013-07-30 15:32:21 +08:00
Send (msg);
2013-04-12 23:41:04 +08:00
}
}
2013-07-30 15:32:21 +08:00
public class Program
{
public static void Main (string [] args)
2013-04-12 23:41:04 +08:00
{
2013-10-02 13:39:56 +08:00
var wssv = new WebSocketServer ("ws://dragonsnest.far");
wssv.AddWebSocketService< Laputa > ("/Laputa");
2013-07-30 15:32:21 +08:00
wssv.Start ();
Console.ReadKey (true);
wssv.Stop ();
2013-04-12 23:41:04 +08:00
}
}
}
```
2012-08-04 14:51:31 +08:00
#### Step 1 ####
2012-08-06 22:04:57 +08:00
Required namespace.
2012-08-04 14:51:31 +08:00
2012-08-08 10:32:19 +08:00
```cs
using WebSocketSharp.Server;
```
2012-08-04 14:51:31 +08:00
2013-10-02 13:39:56 +08:00
The `WebSocketService` and `WebSocketServer` classes exist in the `WebSocketSharp.Server` namespace.
2012-08-04 14:51:31 +08:00
#### Step 2 ####
2013-10-02 13:39:56 +08:00
Creating the class that inherits the `WebSocketService` class.
2012-08-04 14:51:31 +08:00
2013-11-22 20:11:19 +08:00
For example, if you provide an echo service,
2012-08-04 14:51:31 +08:00
2012-08-08 10:20:57 +08:00
```cs
using System;
using WebSocketSharp;
using WebSocketSharp.Server;
public class Echo : WebSocketService
{
2013-07-30 15:32:21 +08:00
protected override void OnMessage (MessageEventArgs e)
2012-08-08 10:20:57 +08:00
{
2013-07-30 15:32:21 +08:00
Send (e.Data);
2012-08-08 10:20:57 +08:00
}
}
```
2012-08-04 14:51:31 +08:00
2013-11-22 20:11:19 +08:00
And if you provide a chat service,
2012-08-04 14:51:31 +08:00
2012-08-08 10:32:19 +08:00
```cs
using System;
using WebSocketSharp;
using WebSocketSharp.Server;
public class Chat : WebSocketService
{
2013-10-02 13:39:56 +08:00
private string _suffix;
public Chat ()
2013-12-03 14:45:14 +08:00
: this (null)
2013-10-02 13:39:56 +08:00
{
}
public Chat (string suffix)
{
2013-12-03 14:45:14 +08:00
_suffix = suffix ?? String.Empty;
2013-10-02 13:39:56 +08:00
}
2013-07-30 15:32:21 +08:00
protected override void OnMessage (MessageEventArgs e)
2012-08-08 10:32:19 +08:00
{
2013-10-02 13:39:56 +08:00
Sessions.Broadcast (e.Data + _suffix);
2012-08-08 10:32:19 +08:00
}
}
```
2012-08-04 14:51:31 +08:00
2013-11-22 20:11:19 +08:00
If you override the `WebSocketService.OnMessage` method, it's bound to the server side `WebSocket.OnMessage` event.
2012-08-13 11:31:11 +08:00
2013-11-22 20:11:19 +08:00
And if you override the `WebSocketService.OnOpen` , `WebSocketService.OnError` and `WebSocketService.OnClose` methods, each of them is bound to each server side event of `WebSocket.OnOpen` , `WebSocket.OnError` and `WebSocket.OnClose` .
2012-08-13 11:31:11 +08:00
2013-11-22 15:15:44 +08:00
The `WebSocketService.Send` method sends a data to the client of the current session to the WebSocket service.
The `WebSocketService.Sessions` (its type is `WebSocketSharp.Server.WebSocketSessionManager` ) property provides some functions for the sessions to the WebSocket service.
2013-11-26 13:36:44 +08:00
The `WebSocketService.Sessions.Broadcast` method sends a data to all clients of the WebSocket service.
2013-11-22 15:15:44 +08:00
2012-08-06 13:34:39 +08:00
#### Step 3 ####
2012-08-04 14:51:31 +08:00
2013-10-02 13:39:56 +08:00
Creating an instance of the `WebSocketServer` class.
2012-09-24 14:01:25 +08:00
```cs
2013-07-30 15:32:21 +08:00
var wssv = new WebSocketServer (4649);
wssv.AddWebSocketService< Echo > ("/Echo");
2013-10-02 14:45:24 +08:00
wssv.AddWebSocketService< Chat > ("/Chat");
wssv.AddWebSocketService< Chat > ("/ChatWithNiceBoat", () => new Chat (" Nice boat."));
2012-09-24 14:01:25 +08:00
```
2013-11-17 15:48:21 +08:00
You can add any WebSocket service with the specified path to the service to your `WebSocketServer` by using the `WebSocketServer.AddWebSocketService<TWithNew>` or `WebSocketServer.AddWebSocketService<T>` method.
2013-10-02 13:39:56 +08:00
The type of `TWithNew` must inherit the `WebSocketService` class and must have a public parameterless constructor.
The type of `T` must inherit `WebSocketService` class.
2012-09-24 14:01:25 +08:00
2013-10-02 13:39:56 +08:00
So you can use the classes created in **Step 2** .
2012-08-04 14:51:31 +08:00
2013-11-26 13:36:44 +08:00
If you create an instance of the `WebSocketServer` class without the port number, the `WebSocketServer` set the port number to **80** automatically. So it's necessary to run with root permission.
2012-08-04 14:51:31 +08:00
2012-08-06 13:34:39 +08:00
$ sudo mono example2.exe
2012-08-04 14:51:31 +08:00
2012-08-06 13:34:39 +08:00
#### Step 4 ####
2012-08-04 14:51:31 +08:00
2012-10-12 13:53:29 +08:00
Starting the server.
2012-08-04 14:51:31 +08:00
2012-08-08 10:32:19 +08:00
```cs
2013-07-30 15:32:21 +08:00
wssv.Start ();
2012-08-08 10:32:19 +08:00
```
2012-08-04 14:51:31 +08:00
2013-08-29 16:01:37 +08:00
#### Step 5 ####
2012-08-04 14:51:31 +08:00
2012-10-12 13:53:29 +08:00
Stopping the server.
2012-08-04 14:51:31 +08:00
2012-08-08 10:32:19 +08:00
```cs
2013-07-30 15:32:21 +08:00
wssv.Stop ();
2012-08-08 10:32:19 +08:00
```
2012-08-04 14:51:31 +08:00
2013-07-01 11:18:26 +08:00
### HTTP Server with the WebSocket ###
2012-09-10 00:36:22 +08:00
2013-11-22 20:11:19 +08:00
I modified the `System.Net.HttpListener` , `System.Net.HttpListenerContext` and some other classes of [Mono] to create the HTTP server that can upgrade the connection to the WebSocket connection when it receives a WebSocket connection request.
2012-09-10 00:36:22 +08:00
2013-11-17 15:48:21 +08:00
You can add any WebSocket service with the specified path to the service to your `HttpServer` by using the `HttpServer.AddWebSocketService<TWithNew>` or `HttpServer.AddWebSocketService<T>` method.
2012-09-10 00:36:22 +08:00
```cs
2013-07-30 15:32:21 +08:00
var httpsv = new HttpServer (4649);
2013-10-02 13:39:56 +08:00
httpsv.AddWebSocketService< Echo > ("/Echo");
2013-10-02 14:45:24 +08:00
httpsv.AddWebSocketService< Chat > ("/Chat");
httpsv.AddWebSocketService< Chat > ("/ChatWithNiceBoat", () => new Chat (" Nice boat."));
2012-09-10 00:36:22 +08:00
```
2013-07-01 11:18:26 +08:00
For more information, could you see ** [Example3]**?
2013-11-05 20:55:16 +08:00
### WebSocket Extensions ###
#### Per-message Compression ####
2013-11-22 15:15:44 +08:00
**websocket-sharp** supports ** [Per-message Compression][compression]** extension. (But it doesn't support with [extension parameters].)
2013-11-05 20:55:16 +08:00
2013-12-01 13:19:04 +08:00
If you enable this extension as a WebSocket client, you should do like the following.
2013-11-05 20:55:16 +08:00
```cs
ws.Compression = CompressionMethod.DEFLATE;
```
2013-11-22 15:15:44 +08:00
And then your WebSocket client sends the following header in the opening handshake to a WebSocket server.
2013-11-05 20:55:16 +08:00
2013-11-22 20:11:19 +08:00
Sec-WebSocket-Extensions: permessage-deflate
2013-11-05 20:55:16 +08:00
2013-11-22 15:15:44 +08:00
If the server supports this extension, it responds the same header. And when your client receives the header, it enables this extension.
2013-11-05 20:55:16 +08:00
2013-07-19 16:29:58 +08:00
### Secure Connection ###
2013-12-01 13:19:04 +08:00
As a **WebSocket Client** , creating an instance of the `WebSocket` class with the specified **wss** scheme URL to connect.
2013-07-19 16:29:58 +08:00
```cs
2014-01-01 21:09:41 +08:00
using (var ws = new WebSocket ("wss://example.com")) {
2013-07-19 16:29:58 +08:00
...
}
```
2013-11-22 20:11:19 +08:00
If you set the custom validation for the server certificate, you use the `WebSocket.ServerCertificateValidationCallback` property.
2013-07-19 16:29:58 +08:00
```cs
2014-01-01 21:09:41 +08:00
ws.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => {
2013-07-19 16:29:58 +08:00
// Do something to validate the server certificate.
2013-11-26 13:36:44 +08:00
return true; // If the server certificate is valid.
2013-07-19 16:29:58 +08:00
};
```
2013-12-01 13:19:04 +08:00
If you set this property to nothing, the validation does nothing with the server certificate and returns valid.
2013-07-19 16:29:58 +08:00
2013-11-15 21:11:21 +08:00
As a **WebSocket Server** , creating an instance of the `WebSocketServer` or `HttpServer` class with some settings for the secure connection.
2013-07-19 16:29:58 +08:00
```cs
2013-07-30 15:32:21 +08:00
var wssv = new WebSocketServer (4649, true);
wssv.Certificate = new X509Certificate2 ("/path/to/cert.pfx", "password for cert.pfx");
2013-07-19 16:29:58 +08:00
```
2013-07-15 19:42:55 +08:00
### Logging ###
The `WebSocket` class includes own logging functions.
The `WebSocket.Log` property provides the logging functions.
2013-11-22 20:11:19 +08:00
If you change the current logging level (the default is `LogLevel.ERROR` ), you use the `WebSocket.Log.Level` property.
2013-07-15 19:42:55 +08:00
```cs
ws.Log.Level = LogLevel.DEBUG;
```
2013-07-30 15:32:21 +08:00
The above means that the logging outputs with a less than `LogLevel.DEBUG` are not outputted.
2013-07-15 19:42:55 +08:00
2013-11-22 20:11:19 +08:00
And if you output a log, you use any of some output methods. The following outputs a log with `LogLevel.DEBUG` .
2013-07-15 19:42:55 +08:00
```cs
2013-07-30 15:32:21 +08:00
ws.Log.Debug ("This is a debug message.");
2013-07-15 19:42:55 +08:00
```
2013-10-02 13:39:56 +08:00
The `WebSocketServer` and `HttpServer` classes include the same logging functions.
2013-07-15 19:42:55 +08:00
2012-07-31 09:36:52 +08:00
## Examples ##
2013-07-30 15:32:21 +08:00
Examples using **websocket-sharp** .
2012-07-31 09:36:52 +08:00
### Example ###
[Example] connects to the [Echo server] using the WebSocket.
### Example1 ###
2013-07-15 19:42:55 +08:00
[Example1] connects to the [Audio Data delivery server] using the WebSocket ([Example1] is only implemented the chat feature, still unfinished).
2012-07-31 09:36:52 +08:00
2013-07-19 16:29:58 +08:00
And [Example1] uses [Json.NET].
2012-07-31 09:36:52 +08:00
2012-08-04 14:51:31 +08:00
### Example2 ###
2013-07-15 19:42:55 +08:00
[Example2] starts a WebSocket server.
2012-09-10 00:36:22 +08:00
### Example3 ###
2013-07-15 19:42:55 +08:00
[Example3] starts an HTTP server that can upgrade the connection to the WebSocket connection.
2012-08-04 14:51:31 +08:00
2013-07-15 19:42:55 +08:00
Could you access to [http://localhost:4649 ](http://localhost:4649 ) to do **WebSocket Echo Test** with your web browser after [Example3] running?
2012-09-24 14:01:25 +08:00
2013-05-01 13:27:24 +08:00
## Supported WebSocket Specifications ##
2012-07-31 09:36:52 +08:00
2013-11-22 15:15:44 +08:00
**websocket-sharp** supports ** [RFC 6455][rfc6455]** and is based on the following WebSocket references.
2013-10-28 15:29:51 +08:00
2013-11-19 16:15:08 +08:00
- **[The WebSocket Protocol][rfc6455]**
- **[The WebSocket API][api]**
2013-10-28 15:29:51 +08:00
- **[Compression Extensions for WebSocket][compression]**
Thanks for translating to japanese.
2013-11-19 16:15:08 +08:00
- **[The WebSocket Protocol 日本語訳][rfc6455_ja]**
- **[The WebSocket API 日本語訳][api_ja]**
2013-10-28 15:29:51 +08:00
2012-07-31 09:36:52 +08:00
## License ##
2013-11-19 16:15:08 +08:00
**websocket-sharp** is provided under ** [The MIT License]**.
2012-07-31 09:36:52 +08:00
2013-11-18 02:17:18 +08:00
[Audio Data delivery server]: http://agektmr.node-ninja.com:3000
2012-07-31 09:36:52 +08:00
[Echo server]: http://www.websocket.org/echo.html
[Example]: https://github.com/sta/websocket-sharp/tree/master/Example
[Example1]: https://github.com/sta/websocket-sharp/tree/master/Example1
2012-08-04 14:51:31 +08:00
[Example2]: https://github.com/sta/websocket-sharp/tree/master/Example2
2012-09-10 00:36:22 +08:00
[Example3]: https://github.com/sta/websocket-sharp/tree/master/Example3
2012-07-31 09:36:52 +08:00
[Json.NET]: http://james.newtonking.com/projects/json-net.aspx
2013-11-18 02:17:18 +08:00
[Mono]: http://www.mono-project.com
2013-11-17 16:03:52 +08:00
[MonoDevelop]: http://monodevelop.com
2013-11-17 17:10:21 +08:00
[NuGet Gallery]: http://www.nuget.org
[NuGet Gallery: websocket-sharp]: http://www.nuget.org/packages/WebSocketSharp
2013-11-19 16:15:08 +08:00
[The MIT License]: https://raw.github.com/sta/websocket-sharp/master/LICENSE.txt
2013-11-18 03:59:29 +08:00
[Unity]: http://unity3d.com
2013-11-19 16:15:08 +08:00
[api]: http://www.w3.org/TR/websockets
[api_ja]: http://www.hcn.zaq.ne.jp/___/WEB/WebSocket-ja.html
2013-10-28 14:34:21 +08:00
[compression]: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09
2013-11-22 15:15:44 +08:00
[draft-hixie-thewebsocketprotocol-75]: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol-75
[draft-ietf-hybi-thewebsocketprotocol-00]: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00
[draft75]: https://github.com/sta/websocket-sharp/tree/draft75
2013-10-28 14:34:21 +08:00
[extension parameters]: http://tools.ietf.org/html/draft-ietf-hybi-permessage-compression-09#section-8.1
2013-11-22 15:15:44 +08:00
[hybi-00]: https://github.com/sta/websocket-sharp/tree/hybi-00
[master]: https://github.com/sta/websocket-sharp/tree/master
2013-11-19 16:15:08 +08:00
[rfc6455]: http://tools.ietf.org/html/rfc6455
[rfc6455_ja]: http://www.hcn.zaq.ne.jp/___/WEB/RFC6455-ja.html
2013-07-02 10:25:26 +08:00
[websocket-sharp for Unity]: http://u3d.as/content/sta-blockhead/websocket-sharp-for-unity