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); } }
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(); }
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); } }
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); }
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); } }
protected abstract void Process(ByteStreamBuffer steamBuffer);
/// <summary> /// 以二进制方式发送 /// </summary> /// <param name="_commandType"></param> /// <param name="_byteStreamBuffer"></param> public void SendMsg(int _commandType, ByteStreamBuffer _byteStreamBuffer) { SendMsgBase(_commandType, _byteStreamBuffer.ToArray()); }