如何创建使用SuperWebSocket一个WebSocket的服务器 [英] How to create a WebSocket server using SuperWebSocket
问题描述
我创建,需要的WebSocket通信的应用程序。所有我需要的是一个简单的WebSocketServer与线程的可能性。我发现SuperWebSocket能满足我的需求。但是,我用C#可怜的熟悉使得麻烦理解代码。任何人都可以告诉我如何创建一个简单的服务器,应该呼应这是从浏览器/网页传送的消息。我会很感激谁给出了一些很好的方向引导|| ||代码的人。我想不出从他们的示例代码的使用
编辑:
这就是我想要实现的东西。
如果有人说,一个确切的解决方案,我将采取一个
编辑:
罗巴尔已经给了直接回答。这仅仅指刚我怎么用它。
this.NewSessionConnected + =新SessionEventHandler< WebSocketSession>(this.WebSocketServer_NewSessionConnected);
this.NewDataReceived + =新SessionEventHandler< WebSocketSession,字节[]>(this.WebSocketServer_NewDataReceived);
this.NewMessageReceived + =新SessionEventHandler< WebSocketSession,串>(this.WebSocketServer_NewMessageReceived);
this.SessionClosed + =新SessionEventHandler< WebSocketSession,SuperSocket.SocketBase.CloseReason>(this.WebSocketServer_SessionClosed);
有SuperWebSocket的样品样品和测试项目也可以帮助你。
I am creating an application which needs WebSocket Communication. All I need is a simple WebSocketServer with threading possibilities. I found that SuperWebSocket can satisfy my needs. But, my poor familiarity with C# makes trouble in understanding the code. Can anybody show me How to create a simple server Which should echo the message which is sent from the browser/WebPage. I will be very thankful to the person who shows some good direction||guide||code. I couldn't figure out the usage from their sample codes.
EDIT: This is the thing which I want to achieve.
If anybody says an exact solution, I will adopt that one.
EDIT: "Robar" already gave the direct answer . This is jsut How I used it .
this.NewSessionConnected += new SessionEventHandler<WebSocketSession>(this.WebSocketServer_NewSessionConnected);
this.NewDataReceived += new SessionEventHandler<WebSocketSession, byte[]>(this.WebSocketServer_NewDataReceived);
this.NewMessageReceived += new SessionEventHandler<WebSocketSession, string>(this.WebSocketServer_NewMessageReceived);
this.SessionClosed += new SessionEventHandler<WebSocketSession, SuperSocket.SocketBase.CloseReason>(this.WebSocketServer_SessionClosed);
There are samples in SuperWebSocket's samples and the test project also can help you.
这篇关于如何创建使用SuperWebSocket一个WebSocket的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!