Fixed WebSocketServer

This commit is contained in:
sta
2012-08-06 14:34:39 +09:00
parent 9212716319
commit b730e23248
59 changed files with 277 additions and 124 deletions

14
Example2/Chat.cs Normal file
View File

@@ -0,0 +1,14 @@
using System;
using WebSocketSharp;
using WebSocketSharp.Server;
namespace Example2
{
public class Chat : WebSocketService
{
protected override void onMessage(object sender, MessageEventArgs e)
{
Server.Send(e.Data);
}
}
}

14
Example2/Echo.cs Normal file
View File

@@ -0,0 +1,14 @@
using System;
using WebSocketSharp;
using WebSocketSharp.Server;
namespace Example2
{
public class Echo : WebSocketService
{
protected override void onMessage(object sender, MessageEventArgs e)
{
Send(e.Data);
}
}
}

View File

@@ -53,6 +53,8 @@
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Echo.cs" />
<Compile Include="Chat.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

Binary file not shown.

View File

@@ -1,27 +1,15 @@
using System;
using System.Threading;
using WebSocketSharp;
using WebSocketSharp.Server;
namespace Example
namespace Example2
{
public class Program
{
public static void Main (string[] args)
public static void Main(string[] args)
{
//WebSocketServer wssv = new WebSocketServer("ws://localhost");
WebSocketServer wssv = new WebSocketServer("ws://localhost:4649");
wssv.OnConnection += (sender, e) =>
{
WebSocket ws = e.Socket;
ws.OnMessage += (sender_, e_) =>
{
// Echo
ws.Send(e_.Data);
// Chat
//wssv.Send(e_.Data);
};
};
var wssv = new WebSocketServer<Echo>("ws://localhost:4649");
//var wssv = new WebSocketServer<Chat>("ws://localhost:4649");
wssv.Start();
Console.WriteLine(

Binary file not shown.

Binary file not shown.

Binary file not shown.