void OnEvent_OnServerHello(object param) { var msg = param as Msg_G2C_Hello; LocalActorId = msg.LocalId; Debug.Log("OnEvent_OnServerHello " + LocalActorId); }
void OnEvent_OnServerMissFrame(object param) { Debug.Log($"OnEvent_OnServerMissFrame"); var msg = param as Msg_RepMissFrame; _cmdBuffer.PushMissServerFrames(msg.frames, false); }
public void OnMsg_X2Y_RegisterDaemon(IDaemonProxy net, Deserializer reader) { var msg = reader.Parse <Msg_RegisterDaemon>(); Debug.Log("OnMsg_X2Y_RegisterDaemon " + msg.ToString()); //_netServerXS.Border(EMsgXS.X2S_RepMasterInfo, msg); }
protected void C2I_UserLogin(IIncommingMessage reader) { var msg = reader.Parse <Msg_C2I_UserLogin>(); Debug.Log("C2I_UserLogin" + msg); ReqUserInfo(msg, reader); }
public void Upgrade(IEntity iEntity) { var entity = iEntity as GameEntity; var playerCount = _gameConfigService.playerPrefabs.Count; var targetType = entity.unit.detailType + 1; if (targetType >= playerCount) { Debug.Log($"hehe already max level can not upgrade"); return; } var ecsPrefab = _gameConfigService.playerPrefabs[targetType] as ConfigUnit; var rawPos = entity.pos.value; var rawDir = entity.dir.value; ecsPrefab.SetComponentsTo(entity); entity.pos.value = rawPos; entity.dir.value = rawDir; if (!_constStateService.IsVideoLoading) { _viewService.DeleteView(entity.localId.value); _viewService.BindView(entity, (short)(ushort)ecsPrefab.asset.assetId, rawPos, DirUtil.GetDirDeg(rawDir)); } }
public void Init(string ip, int port, string key) { _key = key; this._ip = ip; this._port = port; _listener = new EventBasedNetListener(); _listener.NetworkReceiveEvent += (fromPeer, dataReader, deliveryMethod) => { OnNetMsg(dataReader.GetRemainingBytes()); dataReader.Recycle(); }; _listener.PeerConnectedEvent += (peer) => { UnityEngine.Debug.Log("Connected!!"); _peer = peer; OnConnected?.Invoke(); }; _listener.PeerDisconnectedEvent += (peer, disconnectInfo) => { UnityEngine.Debug.Log("DisConnected!!"); }; _client = new NetManager(_listener) { DisconnectTimeout = 300000 }; _isInit = true; Debug.Log($"Try Connect to {ip}:{port}"); }
public void OnMsg_X2Y_ReqMasterInfo(IDaemonProxy net, Deserializer reader) { var serverInfo = reader.Parse <Msg_ReqMasterInfo>().serverInfo; Debug.Log("OnMsg_X2Y_ReqMasterInfo " + serverInfo.ToString()); var type = (EServerType)serverInfo.serverType; if (serverInfo.isMaster) { _type2MasterInfo[type] = serverInfo; _netServerYX.Border(EMsgYX.Y2X_BorderMasterInfo, new Msg_BorderMasterInfo() { serverInfo = serverInfo }); } if (_type2MasterInfo.Count > 0) { var infos = _type2MasterInfo.Values.ToArray(); net.SendMsg(EMsgYX.Y2X_RepMasterInfo, new Msg_RepMasterInfo() { serverInfos = infos }); } }
public void OnMsg_Y2X_BorderMasterInfo(Deserializer reader) { var msg = reader.Parse <Msg_BorderMasterInfo>(); Debug.Log("OnMsg_Y2X_RepMasterInfo " + msg.ToString()); _netServerXS.Border(EMsgXS.X2S_BorderMasterInfo, msg); }
protected override void OnMasterServerInfo(ServerIpInfo info){ if (info.ServerType == (byte) EServerType.DatabaseServer) { if (_netClientDS != null) return; Debug.Log("OnMasterServerInfo" + info); ReqOtherServerInfo(EServerType.DatabaseServer, (status, respond) => { if (status != EResponseStatus.Failed) { InitClientDS(respond.Parse<Msg_RepOtherServerInfo>().ServerInfo); } }); } if (info.ServerType == (byte) EServerType.LobbyServer) { if (_netClientLI != null) return; Debug.Log("OnMasterServerInfo" + info); ReqOtherServerInfo(EServerType.LobbyServer, (status, respond) => { if (status != EResponseStatus.Failed) { InitClientLI(respond.Parse<Msg_RepOtherServerInfo>().ServerInfo); } }); ReqOtherServerInfo(EServerType.LobbyServer, (status, respond) => { if (status != EResponseStatus.Failed) { lobbyInfo = respond.Parse<Msg_RepOtherServerInfo>().ServerInfo; } }, EServerDetailPortType.TcpPort); } }
private void OnDBConn() { Debug.Log(" OnDBConn"); _netClientDS.Send(EMsgDS.S2D_ReqUserInfo, new Msg_ReqAccountData() { account = "LockstepPlatform", password = "******" }); _netClientDS.Send(EMsgDS.S2D_ReqCreateUser, new Msg_ReqAccountData() { account = "LockstepPlatform", password = "******" }); _netClientDS.Send(EMsgDS.S2D_ReqCreateUser, new Msg_ReqAccountData() { account = "jiepengtan", password = "******" }); _netClientDS.Send(EMsgDS.S2D_ReqUserInfo, new Msg_ReqAccountData() { account = "jiepengtan", password = "******" }); _netClientDS.Send(EMsgDS.S2D_ReqUserInfo, new Msg_ReqAccountData() { account = "LockstepPlatform", password = "******" }); _netClientDS.Send(EMsgDS.S2D_ReqUserInfo, new Msg_ReqAccountData() { account = "hehehe", password = "******" }); }
void OnNet_ReqMissFrame(Player player, BaseFormater data) { var reqMsg = data as Msg_ReqMissFrame; var nextCheckTick = reqMsg.StartTick; Debug.Log($"OnNet_ReqMissFrame nextCheckTick id:{player.localId}:{nextCheckTick}"); var msg = new Msg_RepMissFrame(); int count = Math.Min(Math.Min((Tick - 1), allHistoryFrames.Count) - nextCheckTick, MaxRepMissFrameCountPerPack); if (count <= 0) { return; } var frames = new ServerFrame[count]; for (int i = 0; i < count; i++) { frames[i] = allHistoryFrames[nextCheckTick + i]; Debug.Assert(frames[i] != null); } msg.StartTick = frames[0].Tick; msg.Frames = frames; SendTo(player, EMsgSC.G2C_RepMissFrame, msg, true); }
public bool Fire(int idx) { if (config == null) { return(false); } if (idx < 0 || idx > _skills.Count) { return(false); } //Debug.Log("TryFire " + idx); if (isFiring) { return(false); // } var skill = _skills[idx]; if (skill.Fire()) { _curSkillIdx = idx; return(true); } Debug.Log($"TryFire failure {idx} {skill.CdTimer} {skill.State}"); return(false); }
protected void OnMsg_S2M_RegisterServer(IServerProxy net, Deserializer reader) { Debug.Log("Add a server " + net.EndPoint.ToString()); var msg = reader.Parse <Msg_RegisterServer>(); net.ServerType = (EServerType)msg.serverInfo.serverType; }
public void DoUpdate(float deltaTime) { _networkService.SendPing(_simulatorService.LocalActorId, LTime.realtimeSinceStartupMS); _predictHelper.DoUpdate(deltaTime); int worldTick = _simulatorService.World.Tick; UpdatePingVal(deltaTime); //Debug.Assert(nextTickToCheck <= nextClientTick, "localServerTick <= localClientTick "); //Confirm frames IsNeedRollback = false; while (NextTickToCheck <= MaxServerTickInBuffer && NextTickToCheck < worldTick) { var sIdx = NextTickToCheck % _bufferSize; var cFrame = _clientBuffer[sIdx]; var sFrame = _serverBuffer[sIdx]; if (cFrame == null || cFrame.tick != NextTickToCheck || sFrame == null || sFrame.tick != NextTickToCheck) { break; } //Check client guess input match the real input if (object.ReferenceEquals(sFrame, cFrame) || sFrame.Equals(cFrame)) { NextTickToCheck++; } else { IsNeedRollback = true; break; } } //Request miss frame data int tick = NextTickToCheck; for (; tick <= MaxServerTickInBuffer; tick++) { var idx = tick % _bufferSize; if (_serverBuffer[idx] == null || _serverBuffer[idx].tick != tick) { break; } } MaxContinueServerTick = tick - 1; if (MaxContinueServerTick <= 0) { return; } if (MaxContinueServerTick < CurTickInServer || // has some middle frame pack was lost _nextClientTick > MaxContinueServerTick + (_maxClientPredictFrameCount - 3) //client has predict too much ) { Debug.Log("SendMissFrameReq " + MaxContinueServerTick); _networkService.SendMissFrameReq(MaxContinueServerTick); } }
void OnPursuingFrame() { _constStateService.IsPursueFrame = true; Debug.Log($"PurchaseServering curTick:" + _world.Tick); var progress = _world.Tick * 1.0f / _cmdBuffer.CurTickInServer; EventHelper.Trigger(EEvent.PursueFrameProcess, progress); }
private void OnDBMasterConn() { Debug.Log(" OnDBMasterConn"); _netClientOMS.Send(EMsgMS.S2M_ReqOtherServerInfo, new Msg_ReqOtherServerInfo() { serverType = (byte)EServerType.DatabaseServer }); }
public void OnMsg_S2X_ReqMasterInfo(IServerProxy net, Deserializer reader) { var msg = reader.Parse <Msg_ReqMasterInfo>(); Debug.Log("OnMsg_S2X_ReqMasterInfo " + msg.ToString()); net.ServerType = (EServerType)msg.serverInfo.serverType; msg.serverInfo.ip = net.EndPoint.Address.ToString(); _netClientYX.Send(EMsgYX.X2Y_ReqMasterInfo, msg); }
public void DoDestroy() { Debug.Log("DoDestroy"); _netTcp.SendMessage(EMsgSC.C2L_LeaveRoom, new Msg_C2L_LeaveRoom().ToBytes()); _netUdp?.DoDestroy(); _netTcp?.DoDestroy(); _netTcp = null; _netUdp = null; }
void OnEvent_LevelLoadDone(object param) { Debug.Log($"OnEvent_LevelLoadDone " + _constStateService.IsReconnecting); if (_constStateService.IsReconnecting || _constStateService.IsVideoMode || _constStateService.IsClientMode) { StartSimulate(); } }
public void OnSkillDone(Entity *ptr , ref SkillData skillData ) { if (_id2EntityView.TryGetValue(ptr->LocalId, out var uView)) { uView.OnSkillDone(skillData.AtkRange); } Debug.Log("OnSkillDone"); }
protected void OnMsg_M2S_RepOtherServerInfo(Deserializer reader) { var msg = reader.Parse <Msg_RepOtherServerInfo>(); var info = msg.serverInfo; if (EServerType.DatabaseServer == (EServerType)info.serverType) { Debug.Log("OnMsg_M2S_RepOtherServerInfo " + msg.ToString()); InitNetClient(ref _netClientDS, info.ip, info.port, OnDBConn); } }
void OnHashMatchResult(int tick, long hash, bool isMatched) { if (isMatched) { _hashCodes[tick] = null; } if (!isMatched) { Debug.Log($"!!!!!!!!!!!! Hash not match tick{tick} hash{hash} "); } }
public void RollbackTo(int tick, int maxContinueServerTick, bool isNeedClear = true) { if (tick < 0) { Debug.LogError("Target Tick invalid!" + tick); return; } Debug.Log($" Rollback diff:{Tick - tick} From{Tick}->{tick} maxContinueServerTick:{maxContinueServerTick} {isNeedClear}"); _timeMachineService.RollbackTo(tick); _commonStateService.SetTick(tick); Tick = tick; }
public void SendInput(Msg_PlayerInput input) { _tick2SendTimestamp[input.Tick] = LTime.realtimeSinceStartupMS; #if DEBUG_SHOW_INPUT var cmd = input.Commands[0]; var playerInput = new Deserializer(cmd.content).Parse <Lockstep.Game.PlayerInput>(); if (playerInput.inputUV != LVector2.zero) { Debug.Log($"SendInput tick:{input.Tick} uv:{playerInput.inputUV}"); } #endif _networkService.SendInput(input); }
public void OnMsg_X2S_BorderMasterInfo(Deserializer reader) { var msg = reader.Parse <Msg_BorderMasterInfo>(); Debug.Log("OnMsg_X2S_BorderMasterInfo " + msg.ToString()); if (msg.serverInfo.serverType == (byte)serverType) { Debug.Log("OnMsg_X2S_RepMasterInfo " + msg.ToString()); InitClientMS(msg.serverInfo); } OnMasterServerInfo(msg.serverInfo); }
private void InitClientMS(ServerIpInfo msg) { InitNetClient(ref _netClientMS, msg.ip, msg.port, () => { Debug.Log("Connect Master " + serverType); _netClientMS.Send(EMsgMS.S2M_RegisterServer, new Msg_RegisterServer() { serverInfo = new ServerIpInfo() { serverType = (byte)serverType } }); } ); }
public void SendTo(Player player, EMsgSC type, ISerializable body, bool isNeedDebugSize = false) { var writer = new Serializer(); writer.PutByte((byte)type); body.Serialize(writer); var bytes = Compressor.Compress(writer); if (isNeedDebugSize) { Debug.Log($"msg :type {type} size{bytes.Length}"); } player.SendRoom(bytes); }
protected void G2C_GameStartInfo(object reader) { var msg = reader as Msg_G2C_GameStartInfo; HasRecvGameDta = true; GameStartInfo = msg; _handler.OnGameStartInfo(msg); //TODO temp code HasConnGameTcp = true; HasConnGameUdp = true; CurGameState = EGameState.Loading; _curLoadProgress = 1; EventHelper.Trigger(EEvent.OnGameCreate, msg); Debug.Log("G2C_GameStartInfo"); }
private void InitClientXS() { Debug.Log("InitClientXS " + _allConfig.daemonPort); InitNetClient(ref _netClientXS, "127.0.0.1", _allConfig.daemonPort, () => { Debug.Log("OnConnectedDaemon " + _allConfig.daemonPort); _netClientXS.Send(EMsgXS.S2X_ReqMasterInfo, new Msg_ReqMasterInfo() { serverInfo = new ServerIpInfo() { isMaster = _serverConfig.isMaster, port = _serverConfig.masterPort, serverType = (byte)serverType } }); }); }
protected void OnMsg_S2M_ReqOtherServerInfo(IServerProxy net, Deserializer reader) { var msg = reader.Parse <Msg_ReqOtherServerInfo>(); var type = (EServerType)msg.serverType; Debug.Log("OnMsg_S2M_ReqOtherServerInfo " + type); if (type == serverType) { //TODO var info = GetSlaveServeInfo(); Debug.Log("GetSlaveServeInfo " + info); net.SendMsg(EMsgMS.M2S_RepOtherServerInfo, new Msg_RepOtherServerInfo() { serverInfo = info }); } }