本文整理汇总了C#中WebSocketServer.AddService方法的典型用法代码示例。如果您正苦于以下问题:C# WebSocketServer.AddService方法的具体用法?C# WebSocketServer.AddService怎么用?C# WebSocketServer.AddService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebSocketServer
的用法示例。
在下文中一共展示了WebSocketServer.AddService方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
server = new WebSocketServer(URI.Port);
server.AddService<Echo>(URI.AbsolutePath);
server.Start();
handle = new EventWaitHandle(false, EventResetMode.AutoReset);
}
示例2: Main
public static void Main(string[] args)
{
/* Single service server
//var wssv = new WebSocketServiceHost<Echo>("ws://localhost:4649");
var wssv = new WebSocketServiceHost<Echo>("ws://localhost:4649/Echo");
//var wssv = new WebSocketServiceHost<Echo>("ws://localhost:4649/エコー");
//var wssv = new WebSocketServiceHost<Echo>(4649);
//var wssv = new WebSocketServiceHost<Echo>(4649, "/Echo");
//var wssv = new WebSocketServiceHost<Echo>(4649, "/エコー");
//var wssv = new WebSocketServiceHost<Chat>("ws://localhost:4649");
//var wssv = new WebSocketServiceHost<Chat>("ws://localhost:4649/Chat");
//var wssv = new WebSocketServiceHost<Chat>("ws://localhost:4649/チャット");
//var wssv = new WebSocketServiceHost<Chat>(4649);
//var wssv = new WebSocketServiceHost<Chat>(4649, "/Chat");
//var wssv = new WebSocketServiceHost<Chat>(4649, "/チャット");
//wssv.Sweeped = false; // Stop the Sweep inactive session Timer.
wssv.Start();
Console.WriteLine(
"WebSocket Service Host (url: {0})\n listening on address: {1} port: {2}\n",
wssv.Uri, wssv.Address, wssv.Port);
*/
/// Multi services server
var wssv = new WebSocketServer(4649);
//var wssv = new WebSocketServer("ws://localhost:4649");
//wssv.Sweeped = false; // Stop the Sweep inactive session Timer.
wssv.AddService<Echo>("/Echo");
wssv.AddService<Chat>("/Chat");
//wssv.AddService<Echo>("/エコー");
//wssv.AddService<Chat>("/チャット");
wssv.Start();
Console.WriteLine(
"WebSocket Server listening on port: {0} service path:", wssv.Port);
foreach (var path in wssv.ServicePath)
Console.WriteLine(" {0}", path);
Console.WriteLine();
Console.WriteLine("Press any key to stop server...");
Console.ReadLine();
wssv.Stop();
}
示例3: StartWebSocketServer
void StartWebSocketServer() {
// Multi services server
wssv = new WebSocketServer(4649);
wssv.AddService<GetColor>("/GetColor");
wssv.Start();
print(
"WebSocket Server listening on port:" + wssv.Port + " service path:");
foreach (var path in wssv.ServicePaths)
print(" " + path + "\r\n");
}
示例4: TestFixtureSetUp
public void TestFixtureSetUp()
{
server = new WebSocketServer(URI.Port);
server.AddService<Server>(URI.AbsolutePath);
server.Start();
}
示例5: initial_web_socket_server
void initial_web_socket_server()
{
wssv = new WebSocketServer(4646);
wssv.AddService<GPS>("/gps");
//wssv.AddService<UHF>("/uhf");
wssv.Start();
}