public void SendPlayerData(string clientName) { ConnectedClientDataMsg msg = new ConnectedClientDataMsg(); msg.SteamID = Sync.MyId; msg.Name = clientName; msg.Join = true; var buffer = new byte[1024]; uint length; uint ticketHandle; // TODO: Store handle and end auth session on end if (!MySteam.API.GetAuthSessionTicket(out ticketHandle, buffer, out length)) { MyGuiScreenMainMenu.UnloadAndExitToMenu(); MyGuiSandbox.AddScreen(MyGuiSandbox.CreateMessageBox( messageCaption: MyTexts.Get(MyCommonTexts.MessageBoxCaptionError), messageText: MyTexts.Get(MyCommonTexts.MultiplayerErrorConnectionFailed))); return; } msg.Token = new byte[length]; Array.Copy(buffer, msg.Token, length); ReplicationLayer.SendClientConnected(ref msg); }
public virtual void Tick() { FrameCounter++; ProfilerShort.Begin("SendElapsedGameTime"); if (IsServer && (MySession.Static.ElapsedGameTime - m_lastSentTimeTimestamp).Seconds > 30) { m_lastSentTimeTimestamp = MySession.Static.ElapsedGameTime; SendElapsedGameTime(); } ProfilerShort.End(); ProfilerShort.Begin("Client kick update"); int currentTotalTime = MySandboxGame.TotalTimeInMilliseconds; if (currentTotalTime - m_lastKickUpdate > 20000) { m_tmpClientList.Clear(); foreach (var client in m_kickedClients.Keys) { m_tmpClientList.Add(client); } foreach (var client in m_tmpClientList) { if (currentTotalTime - m_kickedClients[client] > KICK_TIMEOUT_MS) { m_kickedClients.Remove(client); } } m_tmpClientList.Clear(); m_lastKickUpdate = currentTotalTime; } ProfilerShort.End(); ProfilerShort.Begin("ReplicationLayer.SendUpdate"); ReplicationLayer.SendUpdate(); ProfilerShort.End(); // TODO: Remove //if (IsServer) //{ // SendServerPhysicsUpdate(); //} SendWorlds(); SendProfilers(); ProfilerShort.Begin("TransportLayer.Tick"); Sync.Layer.TransportLayer.Tick(); ProfilerShort.End(); ProfilerShort.Begin("Trace, NetProfiler.Commit"); //VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Multiplayer, "============ Frame end ============"); NetProfiler.Commit(); ProfilerShort.End(); }
public void ReportReplicatedObjects() { if (VRage.Profiler.MyRenderProfiler.ProfilerVisible) { ProfilerShort.Begin("ReportReplicatedObjects (only when profiler visible)"); ReplicationLayer.ReportReplicatedObjects(); ProfilerShort.End(); } }
public void SendJoinResult(ulong sendTo, JoinResult joinResult, ulong adminID = 0) { JoinResultMsg msg = new JoinResultMsg(); msg.JoinResult = joinResult; msg.Admin = adminID; ReplicationLayer.SendJoinResult(ref msg, sendTo); }
void SendClientData(ulong steamTo, ulong connectedSteamID, string connectedClientName, bool join) { ConnectedClientDataMsg msg = new ConnectedClientDataMsg(); msg.SteamID = connectedSteamID; msg.Name = connectedClientName; msg.IsAdmin = MySandboxGame.ConfigDedicated.Administrators.Contains(connectedSteamID.ToString()) || MySandboxGame.ConfigDedicated.Administrators.Contains(ConvertSteamIDFrom64(connectedSteamID)); msg.Join = join; ReplicationLayer.SendClientConnected(ref msg, steamTo); }
public virtual void Tick() { FrameCounter++; if (MyFakes.ENABLE_MULTIPLAYER_CONSTRAINT_COMPENSATION && IsServer && FrameCounter % 2 == 0) { MySyncGlobal.SendSimulationInfo(); } if (IsServer && (MySession.Static.ElapsedGameTime - m_lastSentTimeTimestamp).Seconds > 30) { m_lastSentTimeTimestamp = MySession.Static.ElapsedGameTime; MySyncGlobal.SendElapsedGameTime(); } int currentTotalTime = MySandboxGame.TotalTimeInMilliseconds; if (currentTotalTime - m_lastKickUpdate > 20000) { m_tmpClientList.Clear(); foreach (var client in m_kickedClients.Keys) { m_tmpClientList.Add(client); } foreach (var client in m_tmpClientList) { if (currentTotalTime - m_kickedClients[client] > KICK_TIMEOUT_MS) { m_kickedClients.Remove(client); } } m_tmpClientList.Clear(); m_lastKickUpdate = currentTotalTime; } ReplicationLayer.Update(); if (VRageRender.Profiler.MyRenderProfiler.ProfilerVisible) { ReplicationLayer.ReportReplicatedObjects(); } // TODO: Remove //if (IsServer) //{ // SendServerPhysicsUpdate(); //} Sync.Layer.TransportLayer.Tick(); VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Multiplayer, "============ Frame end ============"); NetProfiler.Commit(); }
public virtual void Dispose() { MyTrace.Send(TraceWindow.Multiplayer, "Multiplayer closed"); m_voxelMapData = null; MyNetworkReader.ClearHandler(MyMultiplayer.ControlChannel); SyncLayer.TransportLayer.Clear(); MyNetworkReader.Clear(); m_sendPhysicsStream.Dispose(); ReplicationLayer.Dispose(); MyMultiplayer.Static = null; }
protected override void SendServerData() { ServerBattleDataMsg msg = new ServerBattleDataMsg(); msg.WorldName = m_worldName; msg.GameMode = m_gameMode; msg.HostName = m_hostName; msg.WorldSize = m_worldSize; msg.AppVersion = m_appVersion; msg.MembersLimit = m_membersLimit; msg.DataHash = m_dataHash; msg.BattleData = m_battleData.SaveData(); ReplicationLayer.SendWorldBattleData(ref msg); }
protected override void SendServerData() { ServerDataMsg msg = new ServerDataMsg(); msg.WorldName = m_worldName; msg.GameMode = m_gameMode; msg.InventoryMultiplier = m_inventoryMultiplier; msg.AssemblerMultiplier = m_assemblerMultiplier; msg.RefineryMultiplier = m_refineryMultiplier; msg.WelderMultiplier = m_welderMultiplier; msg.GrinderMultiplier = m_grinderMultiplier; msg.HostName = m_hostName; msg.WorldSize = m_worldSize; msg.AppVersion = m_appVersion; msg.MembersLimit = m_membersLimit; msg.DataHash = m_dataHash; ReplicationLayer.SendWorldData(ref msg); }
void ClientConnected(VRage.MyPacket packet) { ConnectedClientDataMsg msg = ReplicationLayer.OnClientConnected(packet); OnConnectedClient(ref msg, msg.SteamID); }
public static void RaiseStaticEvent <T2, T3, T4, T5, T6, T7>(Func <IMyEventOwner, Action <T2, T3, T4, T5, T6, T7> > action, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, EndpointId targetEndpoint = new EndpointId(), Vector3D?position = new Vector3D?()) { ReplicationLayer.RaiseEvent <IMyEventOwner, T2, T3, T4, T5, T6, T7, IMyEventOwner>(null, null, action, arg2, arg3, arg4, arg5, arg6, arg7, targetEndpoint, position); }
public static void RaiseStaticEvent <T2, T3>(Func <IMyEventOwner, Action <T2, T3> > action, T2 arg2, T3 arg3, EndpointId targetEndpoint = new EndpointId(), Vector3D?position = new Vector3D?()) { ReplicationLayer.RaiseEvent <IMyEventOwner, T2, T3, IMyEventOwner>(null, null, action, arg2, arg3, targetEndpoint, position); }
public static void RaiseStaticEvent(Func <IMyEventOwner, Action> action, EndpointId targetEndpoint = new EndpointId(), Vector3D?position = new Vector3D?()) { ReplicationLayer.RaiseEvent <IMyEventOwner, IMyEventOwner>(null, null, action, targetEndpoint, position); }
public static void RaiseEvent <T1, T2, T3, T4, T5, T6, T7>(T1 arg1, Func <T1, Action <T2, T3, T4, T5, T6, T7> > action, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, EndpointId targetEndpoint = new EndpointId()) where T1 : IMyEventOwner { Vector3D?position = null; ReplicationLayer.RaiseEvent <T1, T2, T3, T4, T5, T6, T7, IMyEventOwner>(arg1, null, action, arg2, arg3, arg4, arg5, arg6, arg7, targetEndpoint, position); }
public static void RaiseEvent <T1, T2, T3>(T1 arg1, Func <T1, Action <T2, T3> > action, T2 arg2, T3 arg3, EndpointId targetEndpoint = new EndpointId()) where T1 : IMyEventOwner { Vector3D?position = null; ReplicationLayer.RaiseEvent <T1, T2, T3, IMyEventOwner>(arg1, null, action, arg2, arg3, targetEndpoint, position); }