private static void TESTMSG_RECIVE(JHSNetworkMessage netMsg) { uint connectionId = netMsg.conn.connectionId; string ip = netMsg.conn.IP; SearchMatch packet = netMsg.ReadMessage <SearchMatch>(); if (packet != null) { JHSDebug.Log(packet.op.ToString()); netMsg.conn.Send(100, new SearchMatch() { op = SearchMatchOperations.Search }); netMsg.conn.Send(100, new SearchMatch() { op = SearchMatchOperations.START, IP = "127.0.0.1", port = 1985 }); // JHSNetworkManager.SendToAll(100, new TESTMSGRE() {ClientId = connectionId, Time = packet.Time, TimeServ = JHSTime.TimeStamp }); } }
internal void HandleClientHandShake(JHSNetworkMessage netMsg) { HandShakeMsg packet = netMsg.ReadMessage <HandShakeMsg>(); if (packet != null) { if (packet.OP == 0) //VER VERSION { netMsg.conn.connectionId = packet.Version; netMsg.conn.stage = PerStage.Connecting; HandShakeMsg p = new HandShakeMsg { Version = (uint)NetConfig.Key, OP = 1 }; netMsg.conn.Send(InternalMessages.HeandShake_Server, p); } else if (packet.OP == 1) { if (packet.Version == NetConfig.Key) { netMsg.conn.stage = PerStage.Connected; HandShakeMsg p = new HandShakeMsg { Version = (uint)NetConfig.Key, OP = 2 }; netMsg.conn.Send(InternalMessages.HeandShake_Server, p); ClientConnected = true; connection = netMsg.conn; PushMessage(new JHSNetworkMessage { msgType = InternalMessages.CONNECTED, conn = netMsg.conn, reader = new JHSNetworkReader() }); } } } }
public static void PushMessage(JHSNetworkMessage msg) { Instance.AddMsg(msg); }
internal bool InvokeHandler(JHSNetworkMessage netMsg) { m_MessageHandlers.GetHandler(netMsg.msgType)?.Invoke(netMsg); return(true); }
internal void AddMsg(JHSNetworkMessage msg) { lock (recieved) recieved.Enqueue(msg); }
public static void PushMessage(JHSNetworkMessage msg) { Instance.InvokeHandler(msg); }
internal void HandleServerHandShake(JHSNetworkMessage netMsg) { HandShakeMsg packet = netMsg.ReadMessage <HandShakeMsg>(); if (packet != null) { if (packet.OP == 0) //VER VERSION { if (packet.Version == NetConfig.Version) { netMsg.conn.stage = PerStage.Verifying; HandShakeMsg p = new HandShakeMsg { Version = netMsg.conn.connectionId, OP = 0 }; netMsg.conn.Send(InternalMessages.HeandShake_Client, p); } else { netMsg.conn.Disconnect(); } } else if (packet.OP == 1) { if (packet.Version == NetConfig.Key) { netMsg.conn.stage = PerStage.Connecting; HandShakeMsg p = new HandShakeMsg { Version = (uint)NetConfig.Key, OP = 1 }; netMsg.conn.Send(InternalMessages.HeandShake_Client, p); } else { netMsg.conn.Disconnect(); } } else if (packet.OP == 2) { if (packet.Version == NetConfig.Key) { netMsg.conn.stage = PerStage.Connected; if (NetConfig.logFilter >= JHSLogFilter.Log) { JHSDebug.Log("JHSNetworkManager :: Connected:" + netMsg.conn.connectionId); } AddConnection(netMsg.conn); } else { netMsg.conn.Disconnect(); } } else { netMsg.conn.Disconnect(); } } }