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


C# WebSocketSession.SendResponse方法代码示例

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


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

示例1: ExecuteCommand

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

示例2: ExecuteCommand

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

示例3: socketServer_NewSessionConnected

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

            if (Kinesis.gKinesis._sensor != null && Kinesis.gKinesis._sensor.Status == KinectStatus.Connected)
            {
                session.SendResponse("{\"Kinect\":\"Connected\"}");
            }

            Kinesis.gKinesis.SetupSkeletonTracker();
        }
开发者ID:Kinesis-io,项目名称:Kinesis.io-SDK-With-Installer,代码行数:12,代码来源:Server.cs

示例4: ExecuteCommand

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

示例5: ExecuteCommand

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

示例6: server_NewSessionConnected

        void server_NewSessionConnected(WebSocketSession session)
        {
            ClientCount++;
            UpdateList();

            session.SendResponse(String.Format("timer|{0}", CurrentSeconds));
            sessions.Add(new ListElement(session));
        }
开发者ID:xedoc,项目名称:SynchroStart,代码行数:8,代码来源:MainForm.cs

示例7: m_WebSocketServer_NewDataReceived

 void m_WebSocketServer_NewDataReceived(WebSocketSession session, byte[] e)
 {
     //Echo
     session.SendResponse(e, 0, e.Length);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:5,代码来源:WebSocketClientTest.cs

示例8: m_WebSocketServer_NewMessageReceived

 void m_WebSocketServer_NewMessageReceived(WebSocketSession session, string e)
 {
     Console.WriteLine("Server:" + e);
     session.SendResponse(e);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:5,代码来源:WebSocketTest.cs

示例9: _webSocketServer_NewMessageReceived

        private void _webSocketServer_NewMessageReceived(WebSocketSession session, string e)
        {
            dynamic received = JsonConvert.DeserializeObject(e);
            if (received is string)
            {
                if ((received as string)[0].Equals('.'))
                {
                    ConsoleWriter.WriteLine(WriteType.Log, "\r[{0}] Command received: {1} - ID: '{2}' ORIGIN: '{3}'", DateTime.Now, received, session.SessionID, session.Origin);
                    string command = (received as string).Substring(1);
                    if (!string.IsNullOrWhiteSpace(command))
                    {
                        string[] line = command.Split(new[] { " " }, StringSplitOptions.None);
                        string[] args = new string[line.Length - 1];
                        Array.Copy(line, 1, args, 0, line.Length - 1);
                        ConsoleManager.InvokeHandler(line[0].ToLower(), args);
                    }
                    ConsoleWriter.Write(WriteType.CMD, "MC> {0}", ConsoleManager.ConInput);
                }
                else
                {
                    var sessions = _webSocketServer.GetAllSessions();
                    foreach (
                        var webSocketSession in
                            sessions.Where(webSocketSession => !webSocketSession.SessionID.Equals(session.SessionID)))
                    {
                        webSocketSession.SendResponse(e);
                    }
                }
            } else if(received != null)
            {
                Response response;
                dynamic result;
                switch ((string)received.rpc)
                {
                    case "Framework.Cache.GlobalCache.GetCache":
                        ConsoleWriter.WriteLine(WriteType.Log, "\r[{0}] RPC received to: {1}({2})",
                            DateTime.Now, received.rpc, JsonConvert.SerializeObject(((JArray)received.args).Values<string>().ToList()));
                        result = InvokeHandler(session, ((string) received.rpc), ((JArray) received.args).Values<string>().ToArray());
                        ConsoleWriter.WriteLine(WriteType.Log, "Result: {0} element...", ((List<IJsonDao>) result).Count);
                        response = new Response
                            {
                                header = "result",
                                response = ((string) received.rpc),
                                args = ((JArray)received.args).Values<string>().ToArray(),
                                data = ((List<IJsonDao>)result)
                            };
                        break;
                    default:
                        ConsoleWriter.WriteLine(WriteType.Log, "\r[{0}] RPC received to: {1}({2})",
                            DateTime.Now, received.rpc, JsonConvert.SerializeObject(((JArray)received.args).Values<string>().ToList()));
                        result = InvokeHandler(session, ((string) received.rpc), ((JArray) received.args).Values<string>().ToArray());
                        response = new Response
                            {
                                header = "result",
                                response = ((string) received.rpc),
                                args = ((JArray)received.args).Values<string>().ToArray(),
                                data = ((bool)result)
                            };
                        break;
                }
                session.SendResponse(JsonConvert.SerializeObject(response));

                ConsoleWriter.Write(WriteType.CMD, "MC> {0}", ConsoleManager.ConInput);
            }
        }
开发者ID:welsen,项目名称:HTML5Magus,代码行数:65,代码来源:WebSocket.cs

示例10: m_WebSocketServer_CommandHandler

 void m_WebSocketServer_CommandHandler(WebSocketSession session, WebSocketCommandInfo commandInfo)
 {
     Console.WriteLine("Server:" + commandInfo.Data);
     session.SendResponse(commandInfo.Data);
 }
开发者ID:RolfEleveld,项目名称:TryoutCSharp,代码行数:5,代码来源:WebSocketTest.cs

示例11: CreatePacketFromMessageAndSend

        /// <summary>
        /// helper function to generate and send byte array message to client session. 
        /// </summary>
        /// <param name="uid">uid of the received message</param>
        /// <param name="message">oodss message</param>
        /// <param name="session">client's websocket session</param>
        /// 
        /// out message format
        ///  0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 .......n     
        /// |length |      uid        |        message ....|
        /// 
        private void CreatePacketFromMessageAndSend(long uid, ServiceMessage message, WebSocketSession session)
        {
            StringBuilder responseMessageStringBuilder = new StringBuilder();
            SimplTypesScope.Serialize(message, responseMessageStringBuilder, StringFormat.Xml);
            string req = responseMessageStringBuilder.ToString();
            //Console.WriteLine("send message: "+ req + " uid "+uid);

            byte[] uidBytes = BitConverter.GetBytes(uid);
            byte[] messageBytes = Encoding.UTF8.GetBytes(req);
            byte[] lengthBytes = BitConverter.GetBytes(uidBytes.Length + messageBytes.Length);
            if (BitConverter.IsLittleEndian)
                Array.Reverse(lengthBytes);
            byte[] outMessage = new byte[lengthBytes.Length + uidBytes.Length + messageBytes.Length];

            Buffer.BlockCopy(lengthBytes, 0, outMessage, 0, lengthBytes.Length);
            Buffer.BlockCopy(uidBytes, 0, outMessage, lengthBytes.Length, uidBytes.Length);
            Buffer.BlockCopy(messageBytes, 0, outMessage, lengthBytes.Length + uidBytes.Length, messageBytes.Length);

            session.SendResponse(outMessage);
            //session.SendResponseAsync(Encoding.UTF8.GetString(outMessage));
        }
开发者ID:ecologylab,项目名称:simplCSharp,代码行数:32,代码来源:WebSocketOODSSServer.cs

示例12: WebSocketServer_NewDataReceived

 protected void WebSocketServer_NewDataReceived(WebSocketSession session, byte[] e)
 {
     session.SendResponse(e);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:4,代码来源:WebSocketTestBase.cs

示例13: WebSocketServer_NewMessageReceived

 protected void WebSocketServer_NewMessageReceived(WebSocketSession session, string e)
 {
     session.SendResponse(e);
 }
开发者ID:xxjeng,项目名称:nuxleus,代码行数:4,代码来源:WebSocketTestBase.cs


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