public void SendProto <T>(int msgDef, T ins) { MemoryStream ms = new MemoryStream(); try { Serializer.Serialize(ms, ins); byte[] msgBytes = ms.ToArray(); ms.SetLength(0); // total length short length = (short)(msgBytes.Length + 6); ms.Write(SSSocketTool.shortToByte2(length), 0, 2); // msgDef ms.Write(SSSocketTool.shortToByte2((short)msgDef), 0, 2); // magic num ms.Write(SSSocketTool.intToByte4(1), 0, 4); // msgBytes ms.Write(msgBytes, 0, msgBytes.Length); // send socketBase.Send(ms.ToArray()); } catch (System.Exception) { SSDebug.Log("SendProto error"); } }
private void DebugPrint(String msg) { if (isDebug) { SSDebug.Log(msg); } }
public void Remove(Object obj) { if (false == m_delegateDic.ContainsKey(obj)) { SSDebug.Log("remove obj error:" + m_msgName); return; } m_delegateDic.Remove(obj); }
public void Add(Object obj, DelegateMessage msgDelegate) { if (m_delegateDic.ContainsKey(obj)) { SSDebug.Log("add delegate repeatedly:" + m_msgName); return; } m_delegateDic.Add(obj, msgDelegate); }
public static void printBytes(byte[] bytes) { string s = ""; for (int i = 0; i < bytes.Length; i++) { s += bytes[i] + ","; } SSDebug.Log(s); }
public static void Init() { SSDebug.Log("Engine.init()"); MessageManager.GetIncestance(); }