private static void TwoPlayerLinkServer() { NetworkManager.Instance.ServerStart(); var ip = NetworkManager.Instance.Server.GetRemoteIP(); var a0 = NetworkManager.Instance.Agent; var data = new LPTC.S2C_RoomIP() { address = ip.Address.GetAddressBytes(), port = ip.Port }; a0.ConenteToClinetServer(ip); a0.Handle_S2C_RoomIP(data); UdpAgent a1 = new UdpAgent(); a1.ConenteToClinetServer(ip); a1.Handle_S2C_RoomIP(data); BattleManager.Instance.GetPlayerModel(0); void TalkTest(int i, C2C_Talk talk) { Debug.Log($"{i}:{talk.talk}".AppendColor(Color.green)); } BattleManager.Instance.GetPlayerModel(0).Handle.AddListener(x => TalkTest(0, x)); BattleManager.Instance.GetPlayerModel(1).Handle.AddListener(x => TalkTest(1, x)); }
public static S2C_RoomIP Parse(byte[] bytes) { S2C_RoomIP value = new S2C_RoomIP(); int start = 4; value.len_address = Helper.To_ushort(bytes, ref start); value.address = Helper.To_byteArray(bytes, ref start, value.len_address); value.port = Helper.To_int(bytes, ref start); return(value); }
public void Handle(byte[] bytes) { if (bytes?.Length < 4) { return; } ushort id = (ushort)(bytes[0] | bytes[1] << 8); ushort len = (ushort)(bytes[2] | bytes[3] << 8); if (bytes?.Length != len + 4) { return; } switch (id) { case 1: C2S_StateChange value_1 = C2S_StateChange.Parse(bytes); m_action_1?.Invoke(value_1); break; case 2: C2S_S2C_Talk value_2 = C2S_S2C_Talk.Parse(bytes); m_action_2?.Invoke(value_2); break; case 3: C2S_BuildRoom value_3 = C2S_BuildRoom.Parse(bytes); m_action_3?.Invoke(value_3); break; case 4: S2C_RoomIP value_4 = S2C_RoomIP.Parse(bytes); m_action_4?.Invoke(value_4); break; case 5: C2S_StartLinkRoom value_5 = C2S_StartLinkRoom.Parse(bytes); m_action_5?.Invoke(value_5); break; case 6: C2S_EndLinkRoom value_6 = C2S_EndLinkRoom.Parse(bytes); m_action_6?.Invoke(value_6); break; case 7: C2S_LinkRoom value_7 = C2S_LinkRoom.Parse(bytes); m_action_7?.Invoke(value_7); break; case 8: S2C_Response_LinkRoom value_8 = S2C_Response_LinkRoom.Parse(bytes); m_action_8?.Invoke(value_8); break; case 9: S2C_RoomState value_9 = S2C_RoomState.Parse(bytes); m_action_9?.Invoke(value_9); break; case 10: C2C_Talk value_10 = C2C_Talk.Parse(bytes); m_action_10?.Invoke(value_10); break; } }
public void Handle(S2C_RoomIP value) { m_action_4?.Invoke(value); }