当前位置: 首页>>代码示例>>C#>>正文


C# NetworkClient类代码示例

本文整理汇总了C#中NetworkClient的典型用法代码示例。如果您正苦于以下问题:C# NetworkClient类的具体用法?C# NetworkClient怎么用?C# NetworkClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetworkClient类属于命名空间,在下文中一共展示了NetworkClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoStep

        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;
        }
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:31,代码来源:LoginStep5_StartChat.cs

示例2: OnStartClient

 public override void OnStartClient(NetworkClient client)
 {
     HideLobbyCamera();
     pauseMenu.SetActive(true);
     ShowHUD();
     Cursor.lockState = CursorLockMode.Locked; // keep confined in the game window
 }
开发者ID:ShadeXIII,项目名称:call-of-senpai-360-no-scope,代码行数:7,代码来源:CustomNetworkManager.cs

示例3: InitializeScene

        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);

        }
开发者ID:wshanshan,项目名称:DDD,代码行数:34,代码来源:GIS_Scene.cs

示例4: UniqueInstance

        public static EventListener UniqueInstance(NetworkClient server)
        {
            if (_uniqueInstance == null)
                _uniqueInstance = new EventListener(server);

            return _uniqueInstance;
        }
开发者ID:wshanshan,项目名称:DDD,代码行数:7,代码来源:EventListener.cs

示例5: SendCharacterCreateCity

        /// <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());
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:30,代码来源:UIPacketSenders.cs

示例6: DoStep

        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;
        }
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:26,代码来源:GameStep_Selling.cs

示例7: SetupClient

 // 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);
 }
开发者ID:LinasKo,项目名称:MetaVerse,代码行数:8,代码来源:NetworkManager.cs

示例8: OnMatchJoined

    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.");

        }
    }
开发者ID:Dotby,项目名称:Funny-heads,代码行数:30,代码来源:ClientEngine.cs

示例9: DoStep

        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;
        }
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:32,代码来源:GameSystemStep_GC.cs

示例10: SetupClient

 public void SetupClient()
 {
     myClient = new NetworkClient();
     myClient.RegisterHandler(MsgType.Connect, OnConnected);
     myClient.Connect("192.16.7.21", 8888);
     isAtStartup = false;
 }
开发者ID:coringuyen,项目名称:Networking,代码行数:7,代码来源:clientandsever.cs

示例11: MainX

        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)
            {
            }
        }
开发者ID:davidajulio,项目名称:hx,代码行数:29,代码来源:Program.cs

示例12: SetSubnetRouteTableTests

        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()));
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:32,代码来源:SetSubnetRouteTableTests.cs

示例13: SetIPForwardingTests

        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()));
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:28,代码来源:SetIPForwardingTests.cs

示例14: DoStep

        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;
        }
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:33,代码来源:LoginStep1_Greeting.cs

示例15: DoStep

        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;
        }
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:29,代码来源:GameSystemStep_Ping.cs


注:本文中的NetworkClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。