通过SuperSocket发送消息



我正在使用SuperWebSocket库来处理WebSocket。我的应用程序正在为连接的客户端发送消息。如何将数据发送到另一个也在使用websocket的服务器?

using SuperSocket.SocketBase;
using System;
using SuperSocket.SocketBase.Protocol;
namespace SuperSocket_Test
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var appServer = new AppServer();
            appServer.Setup(123); //binding to 123 port
            appServer.Start();
            Console.WriteLine("The server started successfully, press key 'q' to stop it!");
            appServer.NewRequestReceived += new RequestHandler<AppSession, StringRequestInfo>(appServer_NewRequestReceived);

            while (Console.ReadKey().KeyChar != 'q')
            {
                Console.WriteLine();                
            }
            appServer.Stop();
            Console.WriteLine("The server was stopped!");
            Console.ReadKey();
        } 
        static void appServer_NewRequestReceived(AppSession session, StringRequestInfo requestInfo)
        {           
            session.Send(requestInfo.Body);            
        }
    }
}

SuperSocket--它只是服务器端的lib。对于客户端,您应该使用Websocket4net

相关内容

  • 没有找到相关文章

最新更新