当前位置: 首页>>代码示例>>C#>>正文


C# WebSocketSession.Close方法代码示例

本文整理汇总了C#中WebSocketSession.Close方法的典型用法代码示例。如果您正苦于以下问题:C# WebSocketSession.Close方法的具体用法?C# WebSocketSession.Close怎么用?C# WebSocketSession.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebSocketSession的用法示例。


在下文中一共展示了WebSocketSession.Close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: appServer_SessionClosed

        static void appServer_SessionClosed(WebSocketSession session, CloseReason closeRs)
        {
            session.Close();
            Console.WriteLine("客户端" + session.RemoteEndPoint.Port + "断开了连接!");
            ClientNum -= 1;

            Console.WriteLine("客户端数目" + ClientNum.ToString());
        }
开发者ID:wsycarlos,项目名称:ARIA,代码行数:8,代码来源:Program.cs

示例2: ProcessMessage

 void ProcessMessage(WebSocketSession session,string type,string[] args)
 {
     switch(type){
     case "join":
         var result=CheckJoinRequset(session,args);
         session.Send(CreateMessage(new[]{"joinres",(string)result.IsSucceeded.ToString(),(string)result.Message}));
         if(result.IsSucceeded){
             if(NewUserAdded!=null){
                 sessions.Add(args[0],session);
                 NewUserAdded(session,new UserEventArgs(args[0]));
             }
         }else session.Close();
         break;
     case "message":
         var name=sessions.FirstOrDefault(pair=>pair.Value==session).Key;
         if(name!=""&&args.Length>0&&MessageReceived!=null)
             MessageReceived(session,new MessageReceivedEventArgs(name,args[0]));
         break;
     case "screenshotres":
         name=sessions.FirstOrDefault(pair=>pair.Value==session).Key;
         if(name!=""&&args.Length>0){
             ThreadPool.QueueUserWorkItem((arg)=>{
                 var data=ConvertData(arg as string);
                 if(ScreenShotReceived!=null)
                     ScreenShotReceived(session,new ScreenShotReceivedEventArgs(name,data));
             },args[0]);
         }
         break;
     default:
         break;
     }
 }
开发者ID:abcsharp,项目名称:RemoteController,代码行数:32,代码来源:Program.cs

示例3: socketServer_NewSessionConnected

        //--------------------------------------------------------------------------------------------------
        //--------------------------------WS     --------------------------------------------------
        //--------------------------------------------------------------------------------------------------

        private static void socketServer_NewSessionConnected(WebSocketSession session)
        {
            var portName = session.Path.Replace("/", "");
            if (portName != null && portName != "")
            {
                portName = portName.Replace("/", "");
                Info("Sock client " + session.SessionID + " connected with path " + portName);
                try
                {
                    var cfg = PortOpen(portName, 0);
                    session.Send(JsonConvert.SerializeObject(cfg));
                    session.Path = portName;
                    return;
                }
                catch (Exception e){
                    session.Send("{ \"error\": \"" + e.Message + "\"}");
                }
            }
            else
            {
                Info("Sock client " + session.SessionID + " connected without path ");
                session.Send(JsonConvert.SerializeObject(ComPortConfigs));
            }
            session.Close();
        }
开发者ID:WebManufacture,项目名称:Legacy.NET,代码行数:29,代码来源:Program.cs

示例4: ExecuteCommand

 public override void ExecuteCommand(WebSocketSession session, SubRequestInfo requestInfo)
 {
     session.Close();
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:4,代码来源:QUIT.cs

示例5: socketServer_NewSessionConnected

        static void socketServer_NewSessionConnected(WebSocketSession session)
        {
            String acceptedOrigin = "http://192.168.31.68";
            //Console.WriteLine(session.RemoteEndPoint.Address.ToString());
            Console.WriteLine(session.Origin);
            if (session.Origin.Equals(acceptedOrigin)) {
                lock (m_SessionSyncRoot)
                    m_Sessions.Add (session);

                SendToAll ("System: " + session.SessionID + " connected");
            } else {
                session.Close(CloseReason.SocketError);
            }
        }
开发者ID:Psyborx,项目名称:c-sharp-websocket-test,代码行数:14,代码来源:Program.cs


注:本文中的WebSocketSession.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。