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


C# WebSocketSession类代码示例

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


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

示例1: HandleMessage

        private async void HandleMessage(WebSocketSession session, string message)
        {
            switch(message)
            {
                case "PokemonList":
                    await PokemonListTask.Execute(_session);
                    break;
                case "EggsList":
                    await EggsListTask.Execute(_session);
                    break;
                case "InventoryList":
                    await InventoryListTask.Execute(_session);
                    break;
            }

            // Setup to only send data back to the session that requested it. 
            try
            {
                dynamic decodedMessage = JObject.Parse(message);
                var handle = _websocketHandler?.Handle(_session, session, decodedMessage);
                if (handle != null)
                    await handle;
            }
            catch
            {
                // ignored
            }
        }
开发者ID:RedNax67,项目名称:NecroBot,代码行数:28,代码来源:WebSocketInterface.cs

示例2: SocketServer_NewDataReceived

        private static void SocketServer_NewDataReceived(WebSocketSession session, byte[] value)
        {
            try
            {
                var request = WebSocketBlockWrite.ByteToPutFileRequest(value);

                switch (request.RequestType)
                {
                    case WebSocketRequestType.PutFileRequest:

                        PutFileResponse putFileResponse = new PutFileResponse
                        {
                            RequestId = request.RequestId,
                            ExecuteSuccess = true
                        };

                        session.Send(JsonConvert.SerializeObject(putFileResponse));
                        //var data = WebSocketBlockWrite.PutFileResponseToByte(putFileResponse);
                        //session.Send(data, 0, data.Length);

                        break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
开发者ID:Jackie-Innover,项目名称:3VR,代码行数:28,代码来源:Program.cs

示例3: ExecuteCommand

 public override void ExecuteCommand(WebSocketSession session, SubRequestInfo requestInfo)
 {
     foreach (var p in requestInfo.Body.Split(' '))
     {
         session.Send(p);
     }
 }
开发者ID:kengoemon,项目名称:WebSocket4Net,代码行数:7,代码来源:ECHO.cs

示例4: Execute

 public static async Task Execute(ISession session, WebSocketSession webSocketSession, string requestID)
 {
     var allPokemonInBag = await session.Inventory.GetHighestsCp(1000);
     var list = new List<PokemonListWeb>();
     allPokemonInBag.ToList().ForEach(o => list.Add(new PokemonListWeb(o)));
     webSocketSession.Send(EncodingHelper.Serialize(new PokemonListResponce(list,requestID)));
 }
开发者ID:ChronoXNL,项目名称:NecroBot,代码行数:7,代码来源:GetPokemonListTask.cs

示例5: socketServer_SessionClosed

        void socketServer_SessionClosed(WebSocketSession session, CloseReason reason)
        {
            if (reason == CloseReason.ServerShutdown)
                return;

            SendToAll("System: " + session.Cookies["name"] + " disconnected");
        }
开发者ID:2594636985,项目名称:SuperWebSocket,代码行数:7,代码来源:Global.asax.cs

示例6: OnMessage

 static void OnMessage(WebSocketSession session, string message)
 {
     Write("Message: {0}", session, message);
     string audience = "http://persona/";
     PersonaClient client = new PersonaClient(message, audience, (PersonaResponse response) => OnPersonaResponse(session, response), (Exception exception) => OnPersonaException(session, exception));
     client.Run();
 }
开发者ID:epicvrvs,项目名称:Voiddekk,代码行数:7,代码来源:Program.cs

示例7: secureSocketServer_NewSessionConnected

 void secureSocketServer_NewSessionConnected(WebSocketSession session)
 {
     lock (m_SecureSessionSyncRoot)
     {
         m_SecureSessions.Add(session);
     }
 }
开发者ID:B3nCr,项目名称:SuperWebSocket,代码行数:7,代码来源:Global.asax.cs

示例8: socketServer_NewSessionConnected

        void socketServer_NewSessionConnected(WebSocketSession session)
        {
            lock (m_SessionSyncRoot)
                m_Sessions.Add(session);

            SendToObserved("System: observe connected",session);
        }
开发者ID:smeshlink,项目名称:CoAP.Proxy,代码行数:7,代码来源:WebSocketService.cs

示例9: ExecuteCommand

 public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo)
 {
     foreach(var p in commandInfo.Parameters)
     {
         session.SendResponse(p);
     }
 }
开发者ID:RolfEleveld,项目名称:TryoutCSharp,代码行数:7,代码来源:ECHO.cs

示例10: secureSocketServer_SessionClosed

 void secureSocketServer_SessionClosed(WebSocketSession session, CloseReason reason)
 {
     lock (m_SecureSessionSyncRoot)
     {
         m_SecureSessions.Remove(session);
     }
 }
开发者ID:B3nCr,项目名称:SuperWebSocket,代码行数:7,代码来源:Global.asax.cs

示例11: InvokeHandler

 private static dynamic InvokeHandler(WebSocketSession session, string command, string[] args)
 {
     if (CommandHandlers.ContainsKey(command))
     {
         return CommandHandlers[command].Invoke(session, args);
     }
     return false;
 }
开发者ID:welsen,项目名称:HTML5Magus,代码行数:8,代码来源:WebSocket.cs

示例12: ExecuteCommand

 public override void ExecuteCommand(WebSocketSession session, SubRequestInfo requestInfo)
 {
     var paramsArray = requestInfo.Body.Split(' ');
     for (var i = 0; i < paramsArray.Length; i++)
     {
         session.Send(paramsArray[i]);
     }
 }
开发者ID:iraychen,项目名称:SuperWebSocket,代码行数:8,代码来源:ECHO.cs

示例13: Execute

 public static async Task Execute(ISession session, WebSocketSession webSocketSession, string requestID)
 {
     var playerStats = (await session.Inventory.GetPlayerStats()).FirstOrDefault();
     if (playerStats == null)
         return;
     var tmpData = new TrainerProfileWeb(session.Profile.PlayerData, playerStats);
     webSocketSession.Send(EncodingHelper.Serialize(new TrainerProfileResponce(tmpData, requestID)));
 }
开发者ID:Chastrol,项目名称:NecroBot,代码行数:8,代码来源:GetTrainerProfileTask.cs

示例14: HandleSession

        private void HandleSession(WebSocketSession session)
        {
            if (_lastProfile != null)
                session.Send(Serialize(_lastProfile));

            if (_lastPokeStopList != null)
                session.Send(Serialize(_lastPokeStopList));
        }
开发者ID:CooLcsgo,项目名称:NecroBot,代码行数:8,代码来源:WebSocketInterface.cs

示例15: SendToAll

 private void SendToAll(WebSocketSession session, string msg)
 {
     //广播
     foreach (var sendSession in session.AppServer.GetAllSessions())
     {
         sendSession.Send(msg);
     }
 }
开发者ID:dingxiaowei,项目名称:WebSocketCSharp,代码行数:8,代码来源:ChatWebSocket.cs


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