Example #1
0
        protected override void Process(ByteStreamBuffer steamBuffer)
        {
            List <string> users = steamBuffer.ReadObject <List <string> >();

            if (users != null)
            {
                Debug.Log("OnlineCommand Send Notification");
                Facade.SendNotification(EventsEnum.ONLINELISTUPDATE, users);
            }
        }
Example #2
0
    private void Start()
    {
        ApplicationFacade f = ApplicationFacade.Instance as ApplicationFacade;

        f.StartUI(this);
        SocketManager s = SocketManager.Instance;

        s.Connect("127.0.0.1", 25565);
        stream = new ByteStreamBuffer();
    }
Example #3
0
 public static void WriteObject(this ByteStreamBuffer steamBuffer, object _object)
 {
     try
     {
         string jsonObject = JsonConvert.SerializeObject(_object);
         steamBuffer.Write_UTF8String(jsonObject);
     }
     catch (System.Exception e)
     {
         Debug.Log(e.Message);
     }
 }
Example #4
0
        protected override void Process(NetCommandData data)
        {
            List <string> onlineList = new List <string>();

            foreach (var client in AsyncClientPool.GetEnumerable())
            {
                onlineList.Add(client._Socket.RemoteEndPoint.ToString());
            }
            ByteStreamBuffer _steamBuffer = new ByteStreamBuffer();

            _steamBuffer.WriteObject(onlineList);
            data.Client.SendMessage(100, _steamBuffer);
        }
Example #5
0
    public static T ReadObject <T>(this ByteStreamBuffer steamBuffer) where T : class
    {
        string jsonObject = steamBuffer.Read_UTF8String();

        try
        {
            return(JsonConvert.DeserializeObject <T>(jsonObject));
        }
        catch (System.Exception e)
        {
            Debug.Log(e.Message);
            return(null);
        }
    }
Example #6
0
 protected abstract void Process(ByteStreamBuffer steamBuffer);
Example #7
0
 /// <summary>
 /// 以二进制方式发送
 /// </summary>
 /// <param name="_commandType"></param>
 /// <param name="_byteStreamBuffer"></param>
 public void SendMsg(int _commandType, ByteStreamBuffer _byteStreamBuffer)
 {
     SendMsgBase(_commandType, _byteStreamBuffer.ToArray());
 }