public void Update() { if (!m_init) { return; } List <NetworkMessage> msgs; for (int i = 0; i < m_clients.Count; ++i) { SyncModelClient client = m_clients[i]; msgs = GetClientMsgs(client.GetPstid()); for (int j = 0; j < msgs.Count; ++j) { client.HandleNetworkMessages(msgs[j]); } msgs.Clear(); client.Update(); } msgs = GetServerMsgs(); for (int i = 0; i < msgs.Count; ++i) { m_server.HandleNetworkMessages(msgs[i]); } msgs.Clear(); m_server.Update(); }
public void Init() { m_ran = new System.Random(); m_server = new SyncModelServer(this); for (int i = 1; i <= CLIENT_COUNT; ++i) { long player_pstid = i; int latency = m_ran.Next(); AddNetWorkPlayer(player_pstid); SyncModelClient client = new SyncModelClient(this, player_pstid, latency); m_clients.Add(client); m_server.OnNetworkMessage_PlayerJoin(player_pstid, latency); } for (int i = 0; i < m_clients.Count; ++i) { m_server.OnNetworkMessage_PlayerReady(m_clients[i].GetPstid()); } m_init = true; }