本文整理汇总了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);
}
}
示例2: ExecuteCommand
public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo)
{
foreach(var p in commandInfo.Parameters)
{
session.SendResponse(p);
}
}
示例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();
}
示例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]);
}
示例5: ExecuteCommand
public override void ExecuteCommand(WebSocketSession session, SubRequestInfo requestInfo)
{
session.SendResponse(requestInfo.Data);
}
示例6: server_NewSessionConnected
void server_NewSessionConnected(WebSocketSession session)
{
ClientCount++;
UpdateList();
session.SendResponse(String.Format("timer|{0}", CurrentSeconds));
sessions.Add(new ListElement(session));
}
示例7: m_WebSocketServer_NewDataReceived
void m_WebSocketServer_NewDataReceived(WebSocketSession session, byte[] e)
{
//Echo
session.SendResponse(e, 0, e.Length);
}
示例8: m_WebSocketServer_NewMessageReceived
void m_WebSocketServer_NewMessageReceived(WebSocketSession session, string e)
{
Console.WriteLine("Server:" + e);
session.SendResponse(e);
}
示例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);
}
}
示例10: m_WebSocketServer_CommandHandler
void m_WebSocketServer_CommandHandler(WebSocketSession session, WebSocketCommandInfo commandInfo)
{
Console.WriteLine("Server:" + commandInfo.Data);
session.SendResponse(commandInfo.Data);
}
示例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));
}
示例12: WebSocketServer_NewDataReceived
protected void WebSocketServer_NewDataReceived(WebSocketSession session, byte[] e)
{
session.SendResponse(e);
}
示例13: WebSocketServer_NewMessageReceived
protected void WebSocketServer_NewMessageReceived(WebSocketSession session, string e)
{
session.SendResponse(e);
}