protected override void OnAfterRead(Network.Client client) { ClickedItem = new Slot(); }
public LoginFailedMessage(Network.Client client, IByteBuffer reader) : base(client, reader) { }
protected override void OnBeforeRead(Network.Client client) { }
protected override void OnAfterWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer) { }
public void Remove(Network.Client client) { RemoveAt(IndexOf(client.Player.CharID)); }
public AudioManager(DCSPlayerRadioInfo playerRadioInfo) { _playerRadioInfo = playerRadioInfo; LogClientId = _playerRadioInfo.radios[0].name; Client = new Network.Client(this, playerRadioInfo); }
public RemoteAgent(int pid) : base(pid) { m_NetworkClient = GameApp.Service<Services.Network>().THSClient; }
protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer) { buffer.WriteVarint(ID); buffer.WriteLong(Time); }
protected override void OnAfterRead(Network.Client client) { client.AddResponse(StateManager.FindState("status").GetSendPacket(0x00)); }
protected override void OnAfterWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer) { client.LastKeepAlive = KeepAlive; }
public TournamentMember this[Network.Client client] { get { return(this[client.Player.CharID]); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public void Update(GameTime gameTime) { // Read input. Vector2 screenDim = _spriteBatch.GetScreenDimensions(); _input = Input.GetState(screenDim, _renderer.RenderState.ScreenToWorldCoordinates); _renderer.RenderState.UpdateAspectRatio(screenDim); _tickTime = gameTime.ElapsedGameTime.TotalMilliseconds; if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.Q)) { IsRunning = false; return; } if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.S) && !_startServer) { _startServer = true; _trollServer = new Network.Server(6667); _trollServer.start(); } if (_input.IsActive(Keys.LeftShift) && _input.IsActive(Keys.S) && _startServer) { _trollServer.stop(); _startServer = false; } if (_input.IsActive(Keys.LeftControl) && _input.IsActive(Keys.C) && !_startClient) { _startClient = true; _trollClient= new Network.Client("192.168.0.3",6667); _trollClient.start(); } if (_input.IsActive(Keys.LeftShift) && _input.IsActive(Keys.C) && _startClient) { _trollClient.stop(); _startClient = false; } // It is important that _worldDate is updated first of all, // since the other components depend on it being in sync. _worldDate.Update(gameTime); // We update the views in reverse order, // because if the input state gets updated by an entity, // enties behind (meaning draw before, meaning having a higher index in _views) it // should get notified, but not entities in front of it. foreach (IView view in _views.Reverse()) { view.Update(_input); } foreach (IModel entity in _models) { entity.Update(_worldDate); } UpdateCamera(); Debug.WriteToScreen("Slow" , gameTime.IsRunningSlowly ? "Yes" : "No"); Debug.WriteToScreen("Zoom" , _renderer.RenderState.Camera.Zoom); Debug.WriteToScreen("Mouse" , _input.ScreenMouse); Debug.WriteToScreen("Mouse rel", _input.MouseRelativeToCenter); }
protected override void OnAfterRead(Network.Client client) { client.PlayerPosition.OnGround = OnGround; }
public static async Task LogTransmissionToDiscord(string transmission, RadioInformation radioInfo, Network.Client client) { transmission += $"\nClients on freq {radioInfo.freq / 1000000}MHz: {string.Join(", ", client.GetHumansOnFreq(radioInfo))}\n" + $"Total / Compatible / On Freq Callsigns : {client.GetHumanSrsClientNames().Count} / {client.GetBotCallsignCompatibleClients().Count} / {client.GetHumansOnFreq(radioInfo).Count}\n" + $"On Freq percentage of Total / Compatible: { Math.Round(client.GetHumansOnFreq(radioInfo).Count / (double)client.GetHumanSrsClientNames().Count * 100, 2) }% / " + $"{ Math.Round(client.GetHumansOnFreq(radioInfo).Count / (double)client.GetBotCallsignCompatibleClients().Count * 100, 2) }%"; if (_socket == null || _socket.ConnectionState != ConnectionState.Connected) { return; } try { using (Constants.ActivitySource.StartActivity("DiscordClient.LogToDiscord", ActivityKind.Client)) { await _socket.GetGuild(TransmissionLogDiscordGuildId) .GetTextChannel(radioInfo.discordTransmissionLogChannelId).SendMessageAsync(transmission); } } catch (Exception e) { Logger.Error(e); } }
protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer) { buffer.WriteVarint(ID); buffer.WriteInt(Id); buffer.WriteByteAngle(HeadYaw); }
protected override void OnAfterRead(Network.Client client) { client.UseEntity(client.ID, Mouse); }
public ServerHelloMessage(Network.Client client, IByteBuffer reader) : base(client, reader) { }
protected override void OnBeforeWrite(Network.Client client, Server.Core.Stream.ByteBuffer buffer) { buffer.WriteVarint(ID); buffer.WriteString("{\"version\":{\"name\":\"1.7.2\",\"protocol\":4},\"players\":{\"max\":" + client.Server._config.maxPlayers + ",\"online\":" + client.Server.GetPlayerCount() + ",\"sample\":[]},\"description\":{\"text\":\"" + client.Server._config.name + "\"},\"favicon\":\"data:image/png;base64,\"}"); }
public static IMap RetrieveMap(string mapID, bool autoActivate) { if (mapID.StartsWith("s")) { IMap map; bool mapLoaded = false; rwLock.EnterUpgradeableReadLock(); try { map = MapManager.UnsafeRetrieveActiveMap(mapID); if (map == null) { using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data)) { map = MapManager.LoadStandardMap(dbConnection, mapID); } mapLoaded = true; if (autoActivate) { rwLock.EnterWriteLock(); try { MapManager.UnsafeAddActiveMap(map); } finally { rwLock.ExitWriteLock(); } } } } finally { rwLock.ExitUpgradeableReadLock(); } if (mapLoaded && autoActivate) { // Spawn everything! map.SpawnNpcs(); map.SpawnItems(); } return(map); } else if (mapID.StartsWith("i")) { // Check if the requested map is already active and loaded IMap map = null; rwLock.EnterUpgradeableReadLock(); try { map = MapManager.UnsafeRetrieveActiveMap(mapID); // Null if map is not loaded if (map == null) { using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data)) { map = LoadInstancedMap(dbConnection, mapID); } bool result = map != null; // Attempt to load the map if (result == true) { if (autoActivate) { // Auto-activate, if needed rwLock.EnterWriteLock(); try { MapManager.UnsafeAddActiveMap(map); } finally { rwLock.ExitWriteLock(); } } Scripting.ScriptManager.InvokeSub("OnMapReloaded", map); } else { map = null; } } } finally { rwLock.ExitUpgradeableReadLock(); } if (map == null) { // Uh oh! We couldn't load the map! Default to the start map map = RetrieveMap(MapManager.GenerateMapID(Settings.Crossroads)); } return(map); } else if (mapID.StartsWith("rd")) { // Check if the requested map is already active and loaded IMap map = null; rwLock.EnterUpgradeableReadLock(); try { map = MapManager.UnsafeRetrieveActiveMap(mapID); // Null if map is not loaded if (map == null) { using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data)) { map = LoadRDungeonMap(dbConnection, mapID); } bool result = map != null; // Attempt to load the map if (result == true) { if (autoActivate) { // Auto-activate, if needed rwLock.EnterWriteLock(); try { MapManager.UnsafeAddActiveMap(map); } finally { rwLock.ExitWriteLock(); } } Scripting.ScriptManager.InvokeSub("OnMapReloaded", map); } else { map = null; } } } finally { rwLock.ExitUpgradeableReadLock(); } if (map == null) { // Uh oh! We couldn't load the map! Default to the start map map = RetrieveMap(MapManager.GenerateMapID(Settings.Crossroads)); } return(map); } else if (mapID.StartsWith("h")) { // Check if the requested map is already active and loaded IMap map = null; bool mapLoaded = false; rwLock.EnterUpgradeableReadLock(); try { map = MapManager.UnsafeRetrieveActiveMap(mapID); // Null if map is not loaded if (map == null) { using (DatabaseConnection dbConnection = new DatabaseConnection(DatabaseID.Data)) { map = LoadHouseMap(dbConnection, mapID); } bool result = map != null; mapLoaded = true; // Attempt to load the map if (result == true) { if (autoActivate) { // Auto-activate, if needed rwLock.EnterWriteLock(); try { MapManager.UnsafeAddActiveMap(map); } finally { rwLock.ExitWriteLock(); } } } else { map = null; } } } finally { rwLock.ExitUpgradeableReadLock(); } //if (map == null) { // // Uh oh! We couldn't load the map! Default to the start map // map = RetrieveMap(MapManager.GenerateMapID(Settings.Crossroads)); //} return(map); } else if (mapID.StartsWith("void")) { IMap map = null; bool mapLoaded = false; rwLock.EnterUpgradeableReadLock(); try { map = MapManager.UnsafeRetrieveActiveMap(mapID); if (map == null) { string charID = mapID.Replace("void-", ""); Network.Client client = Network.ClientManager.FindClientFromCharID(charID); if (client != null) { map = new Void(client.Player); mapLoaded = true; if (autoActivate) { rwLock.EnterWriteLock(); try { MapManager.UnsafeAddActiveMap(map); } finally { rwLock.ExitWriteLock(); } } } else { return(null); } } } finally { rwLock.ExitUpgradeableReadLock(); } if (map != null && mapLoaded && autoActivate) { // Spawn everything! map.SpawnNpcs(); map.SpawnItems(); } return(map); } else { return(RetrieveMap(MapManager.GenerateMapID(Settings.Crossroads))); } }
public void CreateManager(bool multiplayer) { IPersistenceManager persistenceManager; if (resourceManager != null) { if (resourceManager.CurrentUniverse != null) { resourceManager.UnloadUniverse(); } if (resourceManager is IDisposable disposable) { disposable.Dispose(); } resourceManager = null; } if (multiplayer) { var rawIpAddress = settings.Get <string>("server").Trim(); string host; IPAddress iPAddress; int port = -1; if (rawIpAddress[0] == '[' || !IPAddress.TryParse(rawIpAddress, out iPAddress)) //IPV4 || IPV6 without port { string stringIpAddress; if (rawIpAddress[0] == '[') // IPV6 with Port { port = int.Parse(rawIpAddress.Split(':').Last()); stringIpAddress = rawIpAddress.Substring(1, rawIpAddress.IndexOf(']') - 1); } else if (rawIpAddress.Contains(':') && IPAddress.TryParse(rawIpAddress.Substring(0, rawIpAddress.IndexOf(':')), out iPAddress)) //IPV4 with Port { port = int.Parse(rawIpAddress.Split(':').Last()); stringIpAddress = iPAddress.ToString(); } else if (rawIpAddress.Contains(':')) //Domain with Port { port = int.Parse(rawIpAddress.Split(':').Last()); stringIpAddress = rawIpAddress.Split(':').First(); } else //Domain without Port { stringIpAddress = rawIpAddress; } host = stringIpAddress; } else { host = rawIpAddress; } var client = new Network.Client(); client.Connect(host, port > 0 ? (ushort)port : (ushort)8888); persistenceManager = new NetworkPersistenceManager(client); networkUpdateManager = new NetworkUpdateManager(client, UpdateHub); } else { persistenceManager = new DiskPersistenceManager(extensionResolver, settings, UpdateHub); } resourceManager = new ResourceManager(extensionResolver, definitionManager, settings, persistenceManager); resourceManager.InsertUpdateHub(UpdateHub as UpdateHub); IsMultiplayer = multiplayer; //if (multiplayer) //{ // resourceManager.GlobalChunkCache.ChunkColumnChanged += (s, c) => // { // var networkPersistence = (NetworkPersistenceManager)persistenceManager; // networkPersistence.SendChangedChunkColumn(c); // }; //} }
protected override void OnAfterRead(Network.Client client) { client.SetTargetMode(NextState); }
void Start() { client = GetComponent <Network.Client>(); }
protected override void OnBeforeWrite(Network.Client client, ByteBuffer buffer) { }
protected override void OnAfterRead(Network.Client client) { }
protected override void OnAfterWrite(Network.Client client, ByteBuffer buffer) { }
public bool Run(System.IO.DirectoryInfo workingDirectory, object options) { RemoteCommandVerbOptions localOptions = options as RemoteCommandVerbOptions; Printer.EnableDiagnostics = localOptions.Verbose; Network.Client client = null; Area ws = null; Tuple<bool, string, int, string> parsedRemoteName = null; if (!string.IsNullOrEmpty(localOptions.Remote)) { if (parsedRemoteName == null) parsedRemoteName = TryParseRemoteName(localOptions.Remote); localOptions.Host = parsedRemoteName.Item2; if (parsedRemoteName.Item3 != -1) localOptions.Port = parsedRemoteName.Item3; localOptions.Module = parsedRemoteName.Item4; } if (NeedsWorkspace) { ws = Area.Load(workingDirectory, Headless); if (ws == null) { Printer.Write(Printer.MessageType.Error, string.Format("#x#Error:##\n The current directory #b#`{0}`## is not part of a vault.\n", workingDirectory.FullName)); return false; } client = new Network.Client(ws); } else { if (NeedsNoWorkspace) { string subdir = localOptions.Name; if (string.IsNullOrEmpty(subdir) && !string.IsNullOrEmpty(localOptions.Module)) subdir = localOptions.Module; if (!string.IsNullOrEmpty(subdir)) { System.IO.DirectoryInfo info; try { info = new System.IO.DirectoryInfo(System.IO.Path.Combine(workingDirectory.FullName, subdir)); } catch { Printer.PrintError("#e#Error - invalid subdirectory \"{0}\"##", subdir); return false; } Printer.PrintMessage("Target directory: #b#{0}##.", info); workingDirectory = info; } try { ws = Area.Load(workingDirectory, Headless); if (ws != null) { CloneVerbOptions cloneOptions = options as CloneVerbOptions; if (cloneOptions != null && cloneOptions.QuietFail) { Printer.PrintMessage("Directory already contains a vault. Skipping."); return false; } Printer.PrintError("This command cannot function with an active Versionr vault."); return false; } } catch { } } client = new Client(workingDirectory); } TargetDirectory = workingDirectory; bool requireRemoteName = false; if (string.IsNullOrEmpty(localOptions.Host) || localOptions.Port == -1) requireRemoteName = true; LocalState.RemoteConfig config = null; if (ws != null) { if (requireRemoteName) config = ws.GetRemote(string.IsNullOrEmpty(localOptions.Name) ? "default" : localOptions.Name); if (UpdateRemoteTimestamp && config != null) ws.UpdateRemoteTimestamp(config); } if (config == null && requireRemoteName) { if (parsedRemoteName != null && parsedRemoteName.Item1 == false) { Printer.PrintError("You must specify either a host and port or a remote name."); return false; } } if (config == null) config = new LocalState.RemoteConfig() { Host = localOptions.Host, Port = localOptions.Port, Module = localOptions.Module }; if (!client.Connect(config.Host, config.Port, config.Module, RequiresWriteAccess)) { Printer.PrintError("Couldn't connect to server!"); return false; } bool result = RunInternal(client, localOptions); client.Close(); return result; }
public ClientHelloMessage(Network.Client client) : base(client) { Id = 10100; }