void UserManagementService_RemoveUserEvent(UserManagementServerNetworkService service, UserManagementServerNetworkService.UserInfo user) { ClientRemoteEntityWorld remoteEntityWorld = GetRemoteEntityWorld(user); if (remoteEntityWorld != null) { networkingInterface.DisconnectRemoteEntityWorld(remoteEntityWorld); clientRemoteEntityWorlds.Remove(remoteEntityWorld); } }
ClientRemoteEntityWorld GetRemoteEntityWorld(NetworkNode.ConnectedNode connectedNode) { for (int n = 0; n < clientRemoteEntityWorlds.Count; n++) { ClientRemoteEntityWorld remoteEntityWorld = clientRemoteEntityWorlds[n]; if (remoteEntityWorld.User.ConnectedNode == connectedNode) { return(remoteEntityWorld); } } return(null); }
public ClientRemoteEntityWorld GetRemoteEntityWorld( UserManagementServerNetworkService.UserInfo user) { for (int n = 0; n < clientRemoteEntityWorlds.Count; n++) { ClientRemoteEntityWorld remoteEntityWorld = clientRemoteEntityWorlds[n]; if (remoteEntityWorld.User == user) { return(remoteEntityWorld); } } return(null); }
protected override SendDataWriter OnBeginEntitySystemMessage( IList <RemoteEntityWorld> toRemoteEntityWorlds, int messageTypeIdentifier) { for (int n = 0; n < toRemoteEntityWorlds.Count; n++) { ClientRemoteEntityWorld remoteEntityWorld = (ClientRemoteEntityWorld)toRemoteEntityWorlds[n]; tempConnectedNodesList.Add(remoteEntityWorld.User.ConnectedNode); } SendDataWriter writer = service.BeginMessage(tempConnectedNodesList, service.entitySystemInternalMessageTypes[messageTypeIdentifier]); tempConnectedNodesList.Clear(); return(writer); }
private void CreateClientRemoteEntityWorldAndSynchronizeWorld( UserManagementServerNetworkService.UserInfo user) { if (user.ConnectedNode != null)//check for local user { { MessageType messageType = GetMessageType("worldCreateBeginToClient"); SendDataWriter writer = BeginMessage(user.ConnectedNode, messageType); writer.Write(World.Instance.Type.Name); if (Map.Instance != null) { writer.Write(Map.Instance.VirtualFileName); } else { writer.Write(""); } writer.Write(worldCheckIdentifier); EndMessage(); } if (GetRemoteEntityWorld(user) == null)//check for arealdy created { //create entity remote world ClientRemoteEntityWorld remoteEntityWorld = new ClientRemoteEntityWorld(user); clientRemoteEntityWorlds.Add(remoteEntityWorld); networkingInterface.ConnectRemoteEntityWorld(remoteEntityWorld); } { MessageType messageType = GetMessageType("worldCreateEndToClient"); SendDataWriter writer = BeginMessage(user.ConnectedNode, messageType); EndMessage(); } } }
private bool ReceiveMessage_CheckWorldIdentifierToServer(NetworkNode.ConnectedNode sender, MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage) { int identifier = reader.ReadInt32(); if (!reader.Complete()) { return(false); } ClientRemoteEntityWorld fromRemoteEntityWorld = GetRemoteEntityWorld(sender); if (fromRemoteEntityWorld == null) { //no such world already. as example World has been deleted. return(true); } fromRemoteEntityWorld.ReceivedWorldIdentifier = identifier; return(true); }
private bool ReceiveMessage_EntitySystemInternal(NetworkNode.ConnectedNode sender, MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage) { ClientRemoteEntityWorld fromRemoteEntityWorld = GetRemoteEntityWorld(sender); if (fromRemoteEntityWorld == null) { //no such world already. as example World has been deleted. return(true); } //check for messages from old/destroyed world. We can get this situation after changing map. if (worldCheckIdentifier != fromRemoteEntityWorld.ReceivedWorldIdentifier) { return(true); } int entitySystemMessageIdentifier = messageType.Identifier - 1; return(networkingInterface.ReceiveEntitySystemMessage(fromRemoteEntityWorld, entitySystemMessageIdentifier, reader, ref additionalErrorMessage)); }
protected override void Dispose() { if (EntitySystemWorld.Instance != null && networkingInterface != null) { while (clientRemoteEntityWorlds.Count != 0) { ClientRemoteEntityWorld remoteEntityWorld = clientRemoteEntityWorlds[0]; networkingInterface.DisconnectRemoteEntityWorld(remoteEntityWorld); clientRemoteEntityWorlds.Remove(remoteEntityWorld); } } if (userManagementService != null) { userManagementService.AddUserEvent -= UserManagementService_AddUserEvent; userManagementService.RemoveUserEvent -= UserManagementService_RemoveUserEvent; } networkingInterface = null; base.Dispose(); }
public void WorldWasDestroyed(bool newMapWillBeLoaded) { foreach (UserManagementServerNetworkService.UserInfo user in userManagementService.Users) { if (user.ConnectedNode != null)//check for local user { MessageType messageType = GetMessageType("worldDestroyToClient"); SendDataWriter writer = BeginMessage(user.ConnectedNode, messageType); writer.Write(newMapWillBeLoaded); EndMessage(); } } if (EntitySystemWorld.Instance != null && networkingInterface != null) { while (clientRemoteEntityWorlds.Count != 0) { ClientRemoteEntityWorld remoteEntityWorld = clientRemoteEntityWorlds[0]; networkingInterface.DisconnectRemoteEntityWorld(remoteEntityWorld); clientRemoteEntityWorlds.Remove(remoteEntityWorld); } } }
void CreateClientRemoteEntityWorldAndSynchronizeWorld( UserManagementServerNetworkService.UserInfo user ) { if( user.ConnectedNode != null )//check for local user { { MessageType messageType = GetMessageType( "worldCreateBeginToClient" ); SendDataWriter writer = BeginMessage( user.ConnectedNode, messageType ); writer.Write( World.Instance.Type.Name ); if( Map.Instance != null ) writer.Write( Map.Instance.VirtualFileName ); else writer.Write( "" ); EndMessage(); } if( GetRemoteEntityWorld( user ) == null )//check for arealdy created { //create entity remote world ClientRemoteEntityWorld remoteEntityWorld = new ClientRemoteEntityWorld( user ); clientRemoteEntityWorlds.Add( remoteEntityWorld ); networkingInterface.ConnectRemoteEntityWorld( remoteEntityWorld ); } { MessageType messageType = GetMessageType( "worldCreateEndToClient" ); SendDataWriter writer = BeginMessage( user.ConnectedNode, messageType ); EndMessage(); } } }