本文整理汇总了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
}
}
示例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);
}
}
示例3: ExecuteCommand
public override void ExecuteCommand(WebSocketSession session, SubRequestInfo requestInfo)
{
foreach (var p in requestInfo.Body.Split(' '))
{
session.Send(p);
}
}
示例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)));
}
示例5: socketServer_SessionClosed
void socketServer_SessionClosed(WebSocketSession session, CloseReason reason)
{
if (reason == CloseReason.ServerShutdown)
return;
SendToAll("System: " + session.Cookies["name"] + " disconnected");
}
示例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();
}
示例7: secureSocketServer_NewSessionConnected
void secureSocketServer_NewSessionConnected(WebSocketSession session)
{
lock (m_SecureSessionSyncRoot)
{
m_SecureSessions.Add(session);
}
}
示例8: socketServer_NewSessionConnected
void socketServer_NewSessionConnected(WebSocketSession session)
{
lock (m_SessionSyncRoot)
m_Sessions.Add(session);
SendToObserved("System: observe connected",session);
}
示例9: ExecuteCommand
public override void ExecuteCommand(WebSocketSession session, StringCommandInfo commandInfo)
{
foreach(var p in commandInfo.Parameters)
{
session.SendResponse(p);
}
}
示例10: secureSocketServer_SessionClosed
void secureSocketServer_SessionClosed(WebSocketSession session, CloseReason reason)
{
lock (m_SecureSessionSyncRoot)
{
m_SecureSessions.Remove(session);
}
}
示例11: InvokeHandler
private static dynamic InvokeHandler(WebSocketSession session, string command, string[] args)
{
if (CommandHandlers.ContainsKey(command))
{
return CommandHandlers[command].Invoke(session, args);
}
return false;
}
示例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]);
}
}
示例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)));
}
示例14: HandleSession
private void HandleSession(WebSocketSession session)
{
if (_lastProfile != null)
session.Send(Serialize(_lastProfile));
if (_lastPokeStopList != null)
session.Send(Serialize(_lastPokeStopList));
}
示例15: SendToAll
private void SendToAll(WebSocketSession session, string msg)
{
//广播
foreach (var sendSession in session.AppServer.GetAllSessions())
{
sendSession.Send(msg);
}
}