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


C# WebSocketSession.Send方法代码示例

本文整理汇总了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)));
 }
开发者ID:ChronoXNL,项目名称:NecroBot,代码行数:7,代码来源:GetPokemonListTask.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: 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

示例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)));
 }
开发者ID:Chastrol,项目名称:NecroBot,代码行数:8,代码来源:GetTrainerProfileTask.cs

示例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);
        }
开发者ID:afeng302,项目名称:WebSocket4Net,代码行数:9,代码来源:Program.cs

示例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);
        }
开发者ID:afeng302,项目名称:WebSocket4Net,代码行数:9,代码来源:Program.cs

示例8: HandleClient

 static void HandleClient(WebSocketSession session)
 {
     while (session.Connected)
     {
         Write("Sending timestamp", session);
         session.Send(GetTimestamp());
         Thread.Sleep(1000);
     }
 }
开发者ID:epicvrvs,项目名称:Voiddekk,代码行数:9,代码来源:Program.cs

示例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
     }));
 }
开发者ID:Chastrol,项目名称:NecroBot,代码行数:10,代码来源:GetPokemonSettingsTask.cs

示例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);
        }
开发者ID:marlonyDevelopers,项目名称:Engine1.1,代码行数:11,代码来源:Program.cs

示例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广播电台");
            }
        }
开发者ID:wsycarlos,项目名称:ARIA,代码行数:12,代码来源:Program.cs

示例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加入了游戏");
            }
        }
开发者ID:wsycarlos,项目名称:ARIA,代码行数:13,代码来源:Program.cs

示例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));
        }
开发者ID:flo-l,项目名称:brettspiel,代码行数:47,代码来源:Program.cs

示例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)));
        }
开发者ID:Chastrol,项目名称:NecroBot,代码行数:20,代码来源:GetEggListTask.cs

示例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

        }
开发者ID:Jackie-Innover,项目名称:3VR,代码行数:36,代码来源:Program.cs


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