// Create a client and connect to the server port public void SetupClient() { myClient = new NetworkClient(); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.RegisterHandler(MyMsgType.Info, OnInfo); myClient.Connect("10.250.235.162", 3000); }
public override void OnStartClient(NetworkClient client) { HideLobbyCamera(); pauseMenu.SetActive(true); ShowHUD(); Cursor.lockState = CursorLockMode.Locked; // keep confined in the game window }
public void connect(string server, NetworkMessageDelegate onConnect) { client = new NetworkClient (); if(onConnect != null) client.RegisterHandler (MsgType.Connect, onConnect); client.Connect (server, PORT); }
public void SetupClient() { myClient = new NetworkClient(); myClient.RegisterHandler(MsgType.Connect, OnConnected); myClient.Connect("192.16.7.21", 8888); isAtStartup = false; }
void Client_ConnectionStatusChanged( NetworkClient sender, NetworkConnectionStatuses status ) { switch( status ) { case NetworkConnectionStatuses.Disconnected: { string text = string.Format( "Disconnected. Reason: \"{0}\"", sender.DisconnectionReason ); Log( text ); Disconnect(); } break; case NetworkConnectionStatuses.Connecting: Log( "Connecting..." ); break; case NetworkConnectionStatuses.Connected: Log( "Connected" ); Log( "Server: \"{0}\"", sender.RemoteServerName ); foreach( string serviceName in sender.ServerConnectedNode.RemoteServices ) Log( "Server service: \"{0}\"", serviceName ); buttonConnect.Enabled = false; buttonDisconnect.Enabled = true; textBoxUserName.ReadOnly = true; textBoxAddress.ReadOnly = true; textBoxEnterText.ReadOnly = false; buttonSend.Enabled = true; break; } }
public bool DoStep(NetworkClient networkClient, GameClient client) { networkClient.OutLogMessage("Getting a servers list..."); //Send greeting string greeting = Packet.BuildPacket(FromClient.GREETING); networkClient.SendData(greeting); //Get response Packet packet = networkClient.InputQueue.Pop(); if (packet != null) { //Get available servers List<string> servers = packet.GetValues("S/@host"); //Log message StringBuilder sServers = new StringBuilder(); //Store available servers foreach (string server in servers) { sServers.AppendFormat("{0}{1}", sServers.Length > 0 ? ", " : "", server); client.AdditionalData.Add(ObjectPropertyName.GAME_SERVER, server); } networkClient.OutLogMessage(sServers.Insert(0, "Available servers: ").ToString()); return true; } networkClient.ThrowError("Failed to getting a servers list or the connection was terminated"); return false; }
public SetSubnetRouteTableTests() { this.networkingClientMock = new Mock<INetworkManagementClient>(); this.computeClientMock = new Mock<IComputeManagementClient>(); this.managementClientMock = new Mock<IManagementClient>(); this.mockCommandRuntime = new MockCommandRuntime(); this.client = new NetworkClient( networkingClientMock.Object, computeClientMock.Object, managementClientMock.Object, mockCommandRuntime); this.networkingClientMock .Setup(c => c.Routes.GetRouteTableForSubnetAsync( VirtualNetworkName, SubnetName, It.IsAny<CancellationToken>())) .Returns(Task.Factory.StartNew(() => new Models.GetRouteTableForSubnetResponse() { RouteTableName = RouteTableName })); this.networkingClientMock .Setup(c => c.Routes.AddRouteTableToSubnetAsync( VirtualNetworkName, SubnetName, It.Is<Models.AddRouteTableToSubnetParameters>( p => string.Equals(p.RouteTableName, RouteTableName)), It.IsAny<CancellationToken>())) .Returns(Task.Factory.StartNew(() => new Azure.OperationStatusResponse())); }
public bool DoStep(NetworkClient networkClient, GameClient client) { Packet[] packets = networkClient.InputQueue.PopAll(FromServer.ERROR); foreach (Packet packet in packets) { string errorCode = packet["@code"]; string errorMessage = Errors.GameError.GetErrorMessage(errorCode); switch (errorCode) { case Errors.GameError.E_USER_HAS_DROPPED: case Errors.GameError.E_PLAYER_ON_ANOTHER_SERVER: case Errors.GameError.E_CONNECTION_ERROR: { networkClient.ThrowError(errorMessage); break; } default: { networkClient.OutLogMessage(string.Format("ERROR: {0}", errorMessage)); break; } } } return true; }
public SetIPForwardingTests() { this.networkingClientMock = new Mock<INetworkManagementClient>(); this.computeClientMock = new Mock<IComputeManagementClient>(); this.managementClientMock = new Mock<IManagementClient>(); this.mockCommandRuntime = new MockCommandRuntime(); this.client = new NetworkClient( networkingClientMock.Object, computeClientMock.Object, managementClientMock.Object, mockCommandRuntime); this.computeClientMock .Setup(c => c.Deployments.GetBySlotAsync(ServiceName, DeploymentSlot.Production, It.IsAny<CancellationToken>())) .Returns(Task.Factory.StartNew(() => new DeploymentGetResponse() { Name = DeploymentName })); this.networkingClientMock .Setup(c => c.IPForwarding.SetOnRoleAsync( ServiceName, DeploymentName, RoleName, It.IsAny<IPForwardingSetParameters>(), It.IsAny<CancellationToken>())) .Returns(Task.Factory.StartNew(() => new Azure.OperationStatusResponse())); }
public static void OnCharacterCreationStatus(NetworkClient Client, ProcessedPacket Packet) { CharacterCreationStatus CCStatus = (CharacterCreationStatus)Packet.ReadByte(); switch (CCStatus) { case CharacterCreationStatus.Success: Guid CharacterGUID = new Guid(); //CityToken didn't exist, so transition to CityServer hasn't happened yet. if (PlayerAccount.CityToken == "") { CharacterGUID = new Guid(Packet.ReadPascalString()); PlayerAccount.CityToken = Packet.ReadPascalString(); } NetworkFacade.Controller._OnCharacterCreationStatus(CCStatus); if(PlayerAccount.CityToken == "") PlayerAccount.CurrentlyActiveSim.AssignGUID(CharacterGUID.ToString()); break; case CharacterCreationStatus.ExceededCharacterLimit: NetworkFacade.Controller._OnCharacterCreationStatus(CCStatus); break; case CharacterCreationStatus.NameAlreadyExisted: NetworkFacade.Controller._OnCharacterCreationStatus(CCStatus); break; case CharacterCreationStatus.GeneralError: NetworkFacade.Controller._OnCharacterCreationStatus(CCStatus); break; default: break; } }
public bool DoStep(NetworkClient networkClient, GameClient client) { int curTickCount = Environment.TickCount; //Just started if (_prewPingTime == 0) { _prewPingTime = curTickCount; return false; } if (curTickCount - _prewPingTime >= PING_DELAY_MS) { //Query params: 0: is a first time ping?, [1]: I1, [2]: ID2, [3]: ID1 string ping = Packet.BuildPacket(FromClient.PING, _firstTime, client.AdditionalData[ObjectPropertyName.I1][0], client.AdditionalData[ObjectPropertyName.ID2][0], client.AdditionalData[ObjectPropertyName.ID1][0]); networkClient.SendData(ping); networkClient.SendChatData(ping); _firstTime = false; _prewPingTime = Environment.TickCount; return true; } return false; }
public void OnMatchJoined(JoinMatchResponse matchJoin) { if (matchJoin.success) { Debug.Log("Join match succeeded"); if (_lobby.matchCreated) { Debug.LogWarning("Match already set up, aborting..."); return; } MatchInfo matchInfo = new MatchInfo(matchJoin); Utility.SetAccessTokenForNetwork(matchJoin.networkId, new NetworkAccessToken(matchJoin.accessTokenString)); _client = new NetworkClient(); _client.RegisterHandler(MsgType.Connect, OnConnected); _client.RegisterHandler(MsgType.Disconnect, OnDisconnect); _client.RegisterHandler(MsgType.Error, OnError); _client.RegisterHandler(MsgType.AddPlayer, AddPlayerMessage); //_client.RegisterHandler(MsgType.Owner, OwnerMes); _client.RegisterHandler(100, MesFromServer); NetworkManager.singleton.StartClient(matchInfo); //_client.Connect(matchInfo); } else { Debug.LogError("Join match failed."); } }
public bool DoStep(NetworkClient networkClient, GameClient client) { if (IsReadyForAction) { DateTime now = DateTime.Now; //Collect garbage IEnumerable<Packet> packets = networkClient.InputQueue.PeakAll(null). Where(p => now.Subtract(p.ReceiveTime).TotalSeconds >= TTL_OF_PACKER_SEC); networkClient.InputQueue.RemoveAll(packets); //Generate list of unknown packets Packet[] unkPackets = packets.Where(p => !_sysPackets.Contains(p.Type)).ToArray(); if (unkPackets.Length > 0) { //Generate log message StringBuilder message = new StringBuilder(); foreach (Packet packet in unkPackets) { message.AppendFormat("{0}{1}", message.Length == 0 ? "" : ", ", packet.Type); } message.Insert(0, "GC -> unknown packets: "); //Send log message networkClient.OutLogMessage(message.ToString()); } _prewGCCollectTime = Environment.TickCount; } return true; }
public bool DoStep(NetworkClient networkClient, GameClient client) { bool chatStarted = false; networkClient.OutLogMessage("Starting chat..."); //Get chat info string getInfo = Packet.BuildPacket(FromClient.CHAT_CTRL, Chat.START); networkClient.SendData(getInfo); //Start chat Packet chat = networkClient.InputQueue.Pop(FromServer.CHAT_CTRL); if (chat != null) { string chatServer = chat["@server"]; string sessionId = (string)client.AdditionalData[ObjectPropertyName.SESSION_ID][0]; chatStarted = networkClient.StartChat(chatServer, sessionId); if (chatStarted) { //1: Session ID, 2: Login string chatAuth = Packet.BuildPacket(FromClient.CHAT_CTRL, Chat.AUTH, sessionId, client.Login); networkClient.SendChatData(chatAuth); } } networkClient.OutLogMessage(!chatStarted ? "WARNING: chat wasn`t started" : "Chat was successfully started"); return true; }
public bool DoStep(NetworkClient networkClient, GameClient client) { if (IsReadyForAction) { _gameItemsGroups = Instance.GameItemsGroups; //Current location must be quction, check it string locationIdent = Helper.GetCurrentLocationIdent(client); if (Locations.Auctions.Contains(locationIdent)) { //Sell items from auc DoSellingItemsFromAuc(networkClient, client); //Sell items from inventory DoSellingItemsFromInv(networkClient, client); } //Clear auction items cache _auctionItems.Clear(); _prewSellingTime = Environment.TickCount; return true; } return false; }
/// <summary> /// Sends a CharacterCreate packet to a CityServer. /// </summary> /// <param name="LoginArgs">Arguments used to log onto the CityServer.</param> /// <param name="Character">The character to create on the CityServer.</param> public static void SendCharacterCreateCity(NetworkClient Client, UISim Character) { PacketStream Packet = new PacketStream((byte)PacketType.CHARACTER_CREATE_CITY, 0); MemoryStream PacketData = new MemoryStream(); BinaryWriter Writer = new BinaryWriter(PacketData); Writer.Write((byte)Client.ClientEncryptor.Username.Length); Writer.Write(Encoding.ASCII.GetBytes(Client.ClientEncryptor.Username), 0, Encoding.ASCII.GetBytes(Client.ClientEncryptor.Username).Length); Writer.Write(PlayerAccount.CityToken); Writer.Write(Character.Timestamp); Writer.Write(Character.Name); Writer.Write(Character.Sex); Writer.Write(Character.Description); Writer.Write((ulong)Character.HeadOutfitID); Writer.Write((ulong)Character.BodyOutfitID); Writer.Write((byte)Character.Avatar.Appearance); Packet.WriteBytes(PacketData.ToArray()); Writer.Close(); Client.SendEncrypted((byte)PacketType.CHARACTER_CREATE_CITY, Packet.ToArray()); }
public bool DoStep(NetworkClient networkClient, GameClient client) { DateTime now = DateTime.Now; ChatMessage[] outChatMessages = _outChatMessages.Where(cm => cm.MessageTime <= now ).ToArray(); if (outChatMessages.Length > 0) { foreach (ChatMessage chatMessage in outChatMessages) { _outChatMessages.Remove(chatMessage); //1: From, 2: To, 3: Type, 4: Message string message = Packet.BuildPacket(FromClient.CHAT_MESSAGE, Chat.POST, client.Login, chatMessage.Sender, chatMessage.Type, chatMessage.Message); networkClient.SendChatData(message); //Play notification for private message _soundPlayer.Play(); //Out chat message string logMessage = string.Format("[{0}] {1} [{2}] {3}", client.Login, chatMessage.Type == ChatMessageType.Pivate ? "private" : "to", chatMessage.Sender, chatMessage.Message); networkClient.OutChatMessage(logMessage); } return true; } return false; }
//automatically called when starting a client public override void OnStartClient(NetworkClient mClient) { Debug.Log ("onstartclient called"); base.OnStartClient(mClient); mClient.RegisterHandler((short)MyMessages.MyMessageTypes.CHAT_MESSAGE, OnClientChatMessage); mClient.RegisterHandler((short)MyMessages.MyMessageTypes.USER_INFO, OnClientUserInfo); }
public static EventListener UniqueInstance(NetworkClient server) { if (_uniqueInstance == null) _uniqueInstance = new EventListener(server); return _uniqueInstance; }
void Start() { if (isLocalPlayer) { nClient = GameObject.Find("NetworkManager").GetComponent<NetworkManager>().client; latencyText = GameObject.Find("Latency Text").GetComponent<Text>(); } }
public void SetupLocalClient() { myClient = ClientScene.ConnectLocalServer (); myClient.RegisterHandler (MsgType.Connect, OnConnectedLocalClient); /*ClientScene.Ready(myClient.connection);*/ ClientScene.AddPlayer (myClient.connection, 0); }
public bool DoStep(NetworkClient networkClient, GameClient client) { //Get game servers list List<object> gameServersList = client.AdditionalData[ObjectPropertyName.GAME_SERVER]; //If servers list is available if (gameServersList != null) { //Connect to the game server while (gameServersList.Count > 0) { //Pop a first game server in the list string server = (string) gameServersList[0]; gameServersList.Remove(server); //Out log message networkClient.OutLogMessage(string.Format("Connecting to the game server: {0}...", server)); //Try to connect bool isConnected = networkClient.ConnectToGameServer(server); if (isConnected) { if (networkClient.DoAuthorization()) { return true; } } } } //Connection failed networkClient.Disconnect(); return false; }
public override void InitializeScene(ICanvas canvas) { // Connect with simulator connection = new NetworkClient(); if (!connection.Connect("ganberg2", 9999)) { throw new ApplicationException("Unable to establish connection with host."); } else { connection.Subscribe("TimeTick"); connection.Subscribe("ViewProUpdate"); } // Create and initialize Gameboard. background = new Obj_Sprite(texture_file, SpriteFlags.SortTexture | SpriteFlags.AlphaBlend); background.Initialize(canvas); background.Position = new Vector3(0, 0, 0); background.Rotation = new Vector3(0, 0, 0); background.Scaling = new Vector3(1, 1, 1); background.Texture(canvas); // Initialize and create Font; this._myFont = canvas.CreateFont(new System.Drawing.Font("Arial", 10)); message = string.Empty; //f16 = new Obj_Sprite("f16.png", SpriteFlags.AlphaBlend); //f16.Initialize(canvas); //f16.Texture(canvas); //f16.Position = new Vector3(0, 0, 0); //f16.Rotation = new Vector3(0, 0, 0); //f16.Scaling = new Vector3(1, 1, 1); }
public static void MainX(string[] args) { ServiceHost service = new ServiceHost(NetworkInput.Instance); ServiceEndpoint endpoint = service.AddServiceEndpoint( typeof(XnaSpace.Input.INetworkInputService), new NetTcpBinding(), args[0]); Console.WriteLine(endpoint.ListenUri); service.Open(); Console.WriteLine("Create Another"); Console.ReadLine(); Binding binding = new NetTcpBinding(); EndpointAddress endpointAddress = new EndpointAddress(args[1]); NetworkClient client = new NetworkClient(binding, endpointAddress); client.Open(); using (Space game = new Space(client)) { game.Run(); } try { client.Close(); service.Close(); } catch (Exception) { } }
void Awake() { Instance = this; mClient = LobbyManager.s_Singleton.client; //NetworkServer.RegisterHandler(MSG_TYPE, OnServerPostChatMessage); }
public static void Main(string[] args) { NetworkClient client = new NetworkClient("127.0.0.1"); client.Connect(); Thread.Sleep(10); client.SendMessage(new GangsterMessage(1001, new Vector2f(1,1))); while(true) {Thread.Sleep(10);} }
/// <summary> /// Requests a token from the LoginServer, that can be used to log into a CityServer. /// </summary> /// <param name="Client">A NetworkClient instance.</param> public static void RequestCityToken(NetworkClient Client, Sim SelectedCharacter) { PacketStream Packet = new PacketStream((byte)PacketType.REQUEST_CITY_TOKEN, 0); Packet.WritePascalString(Client.ClientEncryptor.Username); Packet.WritePascalString(SelectedCharacter.ResidingCity.UUID); Packet.WritePascalString(SelectedCharacter.GUID.ToString()); Client.SendEncrypted((byte)PacketType.REQUEST_CITY_TOKEN, Packet.ToArray()); }
public static void HostP2PServer(string gn) { gameName = gn; myClient = instance.StartHost(); Network.InitializeServer(32, 1337, !Network.HavePublicAddress()); MasterServer.RegisterHost(gameID, gameName); }
public override void OnStartClient (NetworkClient client) { discovery.StartAsClient (); //Debug.Log ("Mother Fuckr"); discovery.showGUI = false; //Debug.Log (discovery.running); }
private void ClientSocketDisconnected(NetworkClient client) { if (client != _networkClient) return; client.IsActive = false; Console.WriteLine("User {0} disconnected", NickName); }
public PlayerSession(NetworkClient _client, uint playerid) { conn = _client; Id = playerid; LoggedTime = DateTime.UtcNow; }
void Start() { lerpRate = normalLerpRate; nwClient = NetworkManager.singleton.client; }
public override void OnStartClient(NetworkClient client) { Debug.Log("Client has started"); }
public void StartHost() { nc = nm.StartHost(); nd.broadcastData = nc.serverIp; Debug.Log(nd.broadcastData); }
void OnStart() { networkClient = FindObjectOfType <NetworkClient>(); }
void OnStartClient_NetworkPortals() { NetworkClient.RegisterHandler <ServerMessageResponseAutoAuth>(OnServerMessageResponseAutoAuth, false); OnClientAuthenticated.AddListener(OnClientAuthenticated_NetworkPortals); }
public void OnStartClient(NetworkClient client) { nd.showGUI = false; }
public override void OnStartClient(NetworkClient myClient) { Debug.Log(Time.timeSinceLevelLoad + " Client start requested."); InvokeRepeating("PrintDots", 0f, 1f); }
public override void OnStartClient(NetworkClient client) { }
static private void VMPacket(NetworkClient client, ProcessedPacket packet) { }
public override void OnStartClient(NetworkClient myNetClient) { Debug.Log(Time.timeSinceLevelLoad + " Client start requested"); InvokeRepeating("PrintConnectingMessage", 0f, 1f); }
public void OnPacket(NetworkClient Client, ProcessedPacket Packet) { Driver.OnPacket(Client, Packet); }
public void FindHost() { nc = nm.StartClient(); Debug.Log(nd.broadcastData); }
public IEnumerator Setup() => UniTask.ToCoroutine(async() => { serverGo = new GameObject("server", typeof(NetworkSceneManager), typeof(ServerObjectManager), typeof(NetworkServer)); clientGo = new GameObject("client", typeof(NetworkSceneManager), typeof(ClientObjectManager), typeof(NetworkClient)); testTransport = serverGo.AddComponent <LoopbackTransport>(); await UniTask.Delay(1); server = serverGo.GetComponent <NetworkServer>(); client = clientGo.GetComponent <NetworkClient>(); server.Transport = testTransport; client.Transport = testTransport; serverSceneManager = serverGo.GetComponent <NetworkSceneManager>(); clientSceneManager = clientGo.GetComponent <NetworkSceneManager>(); serverSceneManager.Server = server; clientSceneManager.Client = client; serverSceneManager.Start(); clientSceneManager.Start(); serverObjectManager = serverGo.GetComponent <ServerObjectManager>(); serverObjectManager.Server = server; serverObjectManager.NetworkSceneManager = serverSceneManager; serverObjectManager.Start(); clientObjectManager = clientGo.GetComponent <ClientObjectManager>(); clientObjectManager.Client = client; clientObjectManager.NetworkSceneManager = clientSceneManager; clientObjectManager.Start(); ExtraSetup(); // create and register a prefab playerPrefab = new GameObject("serverPlayer", typeof(NetworkIdentity), typeof(T)); NetworkIdentity identity = playerPrefab.GetComponent <NetworkIdentity>(); identity.AssetId = Guid.NewGuid(); clientObjectManager.RegisterPrefab(identity); // wait for client and server to initialize themselves await UniTask.Delay(1); // start the server var started = new UniTaskCompletionSource(); server.Started.AddListener(() => started.TrySetResult()); server.StartAsync().Forget(); await started.Task; // now start the client await client.ConnectAsync("localhost"); await AsyncUtil.WaitUntilWithTimeout(() => server.Players.Count > 0); // get the connections so that we can spawn players connectionToClient = server.Players.First(); connectionToServer = client.Player; // create a player object in the server serverPlayerGO = Object.Instantiate(playerPrefab); serverIdentity = serverPlayerGO.GetComponent <NetworkIdentity>(); serverComponent = serverPlayerGO.GetComponent <T>(); serverObjectManager.AddCharacter(connectionToClient, serverPlayerGO); // wait for client to spawn it await AsyncUtil.WaitUntilWithTimeout(() => connectionToServer.Identity != null); clientIdentity = connectionToServer.Identity; clientPlayerGO = clientIdentity.gameObject; clientComponent = clientPlayerGO.GetComponent <T>(); });
// Use this for initialization void Start() { //NetworkDiscovery.StartAsClient(); client = new NetworkClient(); }
public override void OnStartClient(NetworkClient client) { base.OnStartClient(client); OnStart?.Invoke(HostType.Client); }
public ManifestOperations(NetworkClient client) { this._client = client; }
private IEnumerator QueryServerCoroutine(string hostname, int port) { using (var client = new NetworkClient()) { var connectTask = new Task(() => { client.Connect(hostname, port); }); connectTask.Start(); // wait until server is connected while (!connectTask.IsCompleted) { yield return(null); } // make sure connection is successful if (connectTask.IsFaulted) { if (connectTask.IsFaulted || !client.Connected) { throw connectTask.Exception; } } // create handshake to send to server Packet[] handshakePackets = new Packet[] { new HandshakePacket() { Address = hostname, Port = port, NextState = NetworkClient.ProtocolState.STATUS }, new RequestPacket() }; ServerStatus status = new ServerStatus(); var retreiveStatusTask = new Task(() => { // write handshake packets to server client.WritePackets(handshakePackets); // get server data ResponsePacket responsePacket; while (true) { PacketData responsePacketData = client.ReadNextPacket(); // check if it's a response packet if (responsePacketData.ID == 0x00) { responsePacket = new ResponsePacket(responsePacketData); break; } } // send ping var sw = new Stopwatch(); sw.Start(); client.WritePacket(new PingPongPacket()); // wait for pong packet while (true) { if (client.ReadNextPacket().ID == 0x01) { break; } } sw.Stop(); // set server status so the task can end status = new ServerStatus() { Packet = responsePacket, PingTime = (int)sw.ElapsedMilliseconds }; }); retreiveStatusTask.Start(); while (!retreiveStatusTask.IsCompleted) { yield return(null); } if (retreiveStatusTask.IsFaulted) { throw retreiveStatusTask.Exception; } Debug.Log($"Response: {status.Packet.JSONResponse}\nPing: {status.PingTime}ms"); } }
void RegisterClientHandler(NetworkClient client) { client.RegisterHandler(MsgType.Highest + 1 + (short)NetMsgType.SelectCharacter, OnOpenSelectUI); }
private unsafe void Auth_OnConnect(NetworkClient client) { var user = new LoginPlayer(client); client.Owner = user; }
public override void OnStartClient(NetworkClient client) // When a client starts up { //client.RegisterHandler(1000, OnCardMsg); // Not 100% sure what this does }
public override void OnStartClient(NetworkClient client) { base.OnStartClient(client); }
public override void OnLobbyStartClient(NetworkClient client) { Debug.Log("OnLobbyStartClient"); base.OnLobbyStartClient(client); }
public NetworkClient StartHost() { Client = NetworkManager.singleton.StartHost(); return(Client); }
public override void OnStartClient() { NetworkClient.RegisterHandler <JoinRequestResponseMessage>(OnReceivedJoinRequestResponse, false); }
public override void OnStartClient(NetworkClient client) { base.OnStartClient(client); Debug.Log("OnStartClient"); }
/// <summary> /// Sends a packet to the client. /// </summary> /// <param name="Packet">The packet to send.</param> public void Send(DataPacket Packet) { NetworkClient.Send(Packet); }
public override void OnStopClient() { NetworkClient.UnregisterHandler <JoinRequestResponseMessage>(); }
public override void ExecuteCmdlet() { if (!string.IsNullOrWhiteSpace(ResourceGroupName) && !string.IsNullOrWhiteSpace(WebAppName)) { if (ShouldProcess(WebAppName, $"Removing Access Restriction Rule from Web App '{WebAppName}'")) { var webApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, WebAppName, SlotName)); SiteConfig siteConfig = webApp.SiteConfig; var accessRestrictionList = TargetScmSite ? siteConfig.ScmIpSecurityRestrictions : siteConfig.IpSecurityRestrictions; IpSecurityRestriction ipSecurityRestriction = null; bool accessRestrictionExists = false; int ruleTypes = Convert.ToInt32(!string.IsNullOrWhiteSpace(IpAddress)) + Convert.ToInt32(!string.IsNullOrWhiteSpace(ServiceTag)) + Convert.ToInt32(!string.IsNullOrWhiteSpace(SubnetId) || (!string.IsNullOrWhiteSpace(SubnetName) && !string.IsNullOrWhiteSpace(VirtualNetworkName))); if (ruleTypes > 1) { throw new Exception("Please specify only one of: IpAddress or ServiceTag or Subnet"); } foreach (var accessRestriction in accessRestrictionList) { if (!string.IsNullOrWhiteSpace(Name)) { if (!string.IsNullOrWhiteSpace(accessRestriction.Name) && accessRestriction.Name.ToLowerInvariant() == Name.ToLowerInvariant() && accessRestriction.Action.ToLowerInvariant() == Action.ToLowerInvariant()) { ipSecurityRestriction = accessRestriction; accessRestrictionExists = true; break; } } else if (!string.IsNullOrWhiteSpace(IpAddress)) { if (!string.IsNullOrWhiteSpace(accessRestriction.IpAddress) && accessRestriction.IpAddress.ToLowerInvariant() == IpAddress.ToLowerInvariant() && accessRestriction.Action.ToLowerInvariant() == Action.ToLowerInvariant()) { if (!string.IsNullOrWhiteSpace(Name)) { if (!string.IsNullOrWhiteSpace(accessRestriction.Name) && accessRestriction.Name.ToLowerInvariant() != Name.ToLowerInvariant()) { continue; } } ipSecurityRestriction = accessRestriction; accessRestrictionExists = true; break; } } else if (!string.IsNullOrWhiteSpace(ServiceTag)) { if (!string.IsNullOrWhiteSpace(accessRestriction.IpAddress) && accessRestriction.IpAddress.ToLowerInvariant() == ServiceTag.ToLowerInvariant() && accessRestriction.Action.ToLowerInvariant() == Action.ToLowerInvariant()) { if (!string.IsNullOrWhiteSpace(Name)) { if (!string.IsNullOrWhiteSpace(accessRestriction.Name) && accessRestriction.Name.ToLowerInvariant() != Name.ToLowerInvariant()) { continue; } } ipSecurityRestriction = accessRestriction; accessRestrictionExists = true; break; } } else if (!string.IsNullOrWhiteSpace(SubnetId) || (!string.IsNullOrWhiteSpace(SubnetName) && !string.IsNullOrWhiteSpace(VirtualNetworkName))) { var subnet = !string.IsNullOrWhiteSpace(SubnetId) ? SubnetId : SubnetName; var subnetResourceId = NetworkClient.ValidateSubnet(subnet, VirtualNetworkName, ResourceGroupName, DefaultContext.Subscription.Id); if (!string.IsNullOrWhiteSpace(accessRestriction.VnetSubnetResourceId) && accessRestriction.VnetSubnetResourceId.ToLowerInvariant() == subnetResourceId.ToLowerInvariant() && accessRestriction.Action.ToLowerInvariant() == Action.ToLowerInvariant()) { if (!string.IsNullOrWhiteSpace(Name)) { if (!string.IsNullOrWhiteSpace(accessRestriction.Name) && accessRestriction.Name.ToLowerInvariant() != Name.ToLowerInvariant()) { continue; } } ipSecurityRestriction = accessRestriction; accessRestrictionExists = true; break; } } } if (accessRestrictionExists) { accessRestrictionList.Remove(ipSecurityRestriction); // Update web app configuration WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, webApp.Location, WebAppName, SlotName, siteConfig); } if (PassThru) { // Refresh object to get the final state webApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, WebAppName, SlotName)); var accessRestrictionConfig = new PSAccessRestrictionConfig(ResourceGroupName, WebAppName, webApp.SiteConfig, SlotName); WriteObject(accessRestrictionConfig); } } } }
public void RemovesSpawnHandlersFromDictionary() { NetworkClient.spawnHandlers.Add(validPrefabGuid, new SpawnHandlerDelegate(x => null)); NetworkClient.UnregisterSpawnHandler(validPrefabGuid); Assert.IsFalse(NetworkClient.unspawnHandlers.ContainsKey(validPrefabGuid)); }