//private float estimatedServerFrameTime = 0f; public ClientNetworking(SocketWrapperSettings settings, int appId) { FrameID = NetworkConstants.BeforeStartOfGameFrameId; packetDispatcher = new PacketDispatcher(); cpcs = new ClientPlayerConnectionState(new SocketWrapper(settings), appId); // Forward events from the CPCS to IClientNetworking cpcs.OnConnect += () => { OnConnect?.Invoke(); }; cpcs.OnDisconnect += (retry) => { OnDisconnect?.Invoke(retry); }; cpcs.OnLoginResponse += (response) => { OnLoginResponse?.Invoke(response); }; // We want to know when the server tells us it's frameid, so we can keep in sync packetDispatcher.AddListener <ServerTick>(OnServerTickPacket); }
public long AddListener <PACKET_TYPE>(int entityID, Action <PACKET_TYPE> action) where PACKET_TYPE : BasePacket { return(packetDispatcher.AddListener(entityID, action)); }