public void OnData(int connectionId, int channelId, int receiveSize) { GameStatics.OnlineSession.NetBuffer.SeekZero(); NetworkMessageID msgId = (NetworkMessageID)GameStatics.OnlineSession.NetBuffer.ReadInt(); switch (msgId) { case (NetworkMessageID.PlayerRegistration): PlayerRegistrationMsg prm = new PlayerRegistrationMsg(); prm.Deserialize(GameStatics.OnlineSession.NetBuffer); HandlePlayerRegistrationMsg(ref prm, connectionId); break; case (NetworkMessageID.PlayerAdd): PlayerAddMsg pam = new PlayerAddMsg(); pam.Deserialize(GameStatics.OnlineSession.NetBuffer); HandlePlayerAddMsg(ref pam, connectionId); break; case (NetworkMessageID.SceneLoading): SceneLoadingMsg lsm = new SceneLoadingMsg(); lsm.Deserialize(GameStatics.OnlineSession.NetBuffer); HandleLoadSceneMsg(ref lsm); break; } }
public void OnData(int connectionId, int channelId, int receiveSize, int msgId) { NetworkMessageID iMsgId = (NetworkMessageID)msgId; switch (iMsgId) { case (NetworkMessageID.SceneLoading): SceneLoadingMsg slm = new SceneLoadingMsg(); slm.Deserialize(GameStatics.OnlineSession.NetBuffer); HandleLoadSceneMsg(ref slm, connectionId); break; case (NetworkMessageID.TickSync): TickSyncMsg tsm = new TickSyncMsg(); tsm.Deserialize(GameStatics.OnlineSession.NetBuffer); HandleTickSyncMsg(ref tsm, connectionId); break; case (NetworkMessageID.SimpleEvent): SimpleEventMsg sem = new SimpleEventMsg(); sem.Deserialize(GameStatics.OnlineSession.NetBuffer); HandleSimpleEventMsg(connectionId, sem.Event); break; case (NetworkMessageID.SpawnPlayer): SpawnPlayerMsg spm = new SpawnPlayerMsg(); spm.Deserialize(GameStatics.OnlineSession.NetBuffer); HandleSpawnPlayerMsg(ref spm, connectionId); break; case (NetworkMessageID.SpawnCharacter): SpawnCharacterMsg scm = new SpawnCharacterMsg(); scm.Deserialize(GameStatics.OnlineSession.NetBuffer); HandleSpawnCharacterMsg(ref scm); break; case (NetworkMessageID.LazerHit): LazerFireMsg lhm = new LazerFireMsg(); lhm.Deserialize(GameStatics.OnlineSession.NetBuffer); HandleLazerFireMsg(ref lhm); break; } }