本文整理汇总了C#中WebSocketSession.Send方法的典型用法代码示例。如果您正苦于以下问题:C# WebSocketSession.Send方法的具体用法?C# WebSocketSession.Send怎么用?C# WebSocketSession.Send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebSocketSession
的用法示例。
在下文中一共展示了WebSocketSession.Send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)));
}
示例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: 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]);
}
}
示例5: 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)));
}
示例6: wsServer_NewMessageReceived
static void wsServer_NewMessageReceived(WebSocketSession session, string value)
{
Console.WriteLine("wsServer_NewMessageReceived: [" + value + "]");
Console.WriteLine("will echo back ...");
Thread.Sleep(1000);
session.Send(value);
}
示例7: wsServer_NewDataReceived
static void wsServer_NewDataReceived(WebSocketSession session, byte[] value)
{
Console.WriteLine("wsServer_NewDataReceived. Length= [" + value.Length + "]");
Console.WriteLine("will echo back ...");
Thread.Sleep(1000);
session.Send(value, 0, value.Length);
}
示例8: HandleClient
static void HandleClient(WebSocketSession session)
{
while (session.Connected)
{
Write("Sending timestamp", session);
session.Send(GetTimestamp());
Thread.Sleep(1000);
}
}
示例9: Execute
public static async Task Execute(ISession session, WebSocketSession webSocketSession, string requestID)
{
var settings = await session.Inventory.GetPokemonSettings();
webSocketSession.Send(EncodingHelper.Serialize(new WebResponce()
{
Command = "PokemonSettings",
Data = settings,
RequestID = requestID
}));
}
示例10: appServer_NewMessageReceived
private static void appServer_NewMessageReceived(WebSocketSession session, string value)
{
//Console.WriteLine("LLEGO MENSAJE: " + value+", SESSION : "+ session.SessionID);
String type = getMessageType(value);
String mess = getReturnMessage(type);
session.Send(mess);
Console.WriteLine("recibo " + value);
Console.WriteLine("envio " + mess);
}
示例11: appServer_NewDataReceived
static void appServer_NewDataReceived(WebSocketSession session, byte[] value)
{
session.Send("欢迎登陆本系统LinMengUnity3DServer: ");
Console.WriteLine("有客户端消息");
Console.WriteLine("客户端数目" + ClientNum.ToString());
foreach (var ses in session.AppServer.GetAllSessions())
{
ses.Send("给所有客户端广播发送的消息LinMeng广播电台");
}
}
示例12: appServer_NewSessionConnected
static void appServer_NewSessionConnected(WebSocketSession session)
{
session.Send("第一次给客户端发信息Unity3DServer: ");
Console.WriteLine("客户端 :端口" + session.RemoteEndPoint.Port + "连接到服务器了!");
ClientNum += 1;
foreach (var ses in session.AppServer.GetAllSessions())
{
ses.Send("xxx加入了游戏");
}
}
示例13: appServer_NewMessageReceived
static void appServer_NewMessageReceived(WebSocketSession session, string message)
{
JsonObject Answer = new JsonObject();
Console.WriteLine(message);
object BUF;
if (SimpleJson.TryDeserializeObject(message, out BUF))
{
JsonObject Message = (JsonObject)BUF;
switch (Message["type"].ToString())
{
case "join":
Answer.Add("type", "registered");
Answer.Add("player_name", Message["name"].ToString());
//int j1 = 0;
//Console.Write("PlayerID: ");
//int.TryParse(Console.ReadLine(), out j1);
//Answer.Add("player_id",j1);
Answer.Add("player_id", player_count++);
Answer.Add("content_pack", "dev-pack");
break;
case "new_game":
Answer.Add("type", "game_created");
Answer.Add("game_id", "bullshit");
break;
case "request_pack_list":
Answer.Add("type", "pack_list");
Answer.Add("packs", new string[] { "dev-pack" });
break;
case "start":
Answer.Add("type", "next");
Answer.Add("player_id", 0);
break;
case "move_request":
Answer.Add("type", "move");
Answer.Add("player_id", Convert.ToInt32(Message["player_id"]));
Answer.Add("location_id", Convert.ToInt32(Message["location_id"]));
break;
default:
break;
}
}
Console.WriteLine(SimpleJson.SerializeObject(Answer));
session.Send(SimpleJson.SerializeObject(Answer));
}
示例14: Execute
public static async Task Execute(ISession session, WebSocketSession webSocketSession, string requestID)
{
var incubators = (await session.Inventory.GetEggIncubators())
.Where(x => x.UsesRemaining > 0 || x.ItemId == ItemId.ItemIncubatorBasicUnlimited)
.OrderByDescending(x => x.ItemId == ItemId.ItemIncubatorBasicUnlimited)
.ToList();
var unusedEggs = (await session.Inventory.GetEggs())
.Where(x => string.IsNullOrEmpty(x.EggIncubatorId))
.OrderBy(x => x.EggKmWalkedTarget - x.EggKmWalkedStart)
.ToList();
var list = new EggListWeb
{
Incubators = incubators,
UnusedEggs = unusedEggs
};
webSocketSession.Send(EncodingHelper.Serialize(new EggListResponce(list,requestID)));
}
示例15: SocketServer_NewDataReceived
private static void SocketServer_NewDataReceived(WebSocketSession session, byte[] value)
{
//var putFileRequest = WebSocketBlockWrite.ByteToPutFileRequest(value);
//Interlocked.Add(ref _processDataCount, putFileRequest.FileData.Length);
////var putFileResponse = new PutFileResponse
////{
//// RequestId = putFileRequest.RequestId,
//// ExecuteSuccess = true
////};
//session.Send(JsonConvert.SerializeObject(putFileResponse));
//session.Send(putFileResponse.ToString());
#region Send Response
//Interlocked.Add(ref _processDataCount, value.Length);
//response.ResponseType = WebSocketResponseType.PutFileResponse;
////response.RequestId = putFileRequest.RequestId;
//response.ExecuteSuccess = true;
//byte[] responseBytes = WebSocketBlockWrite.ResponseToBytes(response);
//session.Send(responseBytes, 0, responseBytes.Length);
#endregion
#region Signal character
Interlocked.Add(ref _processDataCount, value.Length);
session.Send("0");
#endregion
}