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


C# Client.Connect方法代码示例

本文整理汇总了C#中Client.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Client.Connect方法的具体用法?C# Client.Connect怎么用?C# Client.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


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

示例1: MultiplayerBase

        public MultiplayerBase(string address, int port, PGGI.PGGIProvider provider)
        {
            ISpriteBatchService spriteService = Atom.Shared.Globals.Engine.GetService<ISpriteBatchService>();
            IInputService inputService = Atom.Shared.Globals.Engine.GetService<IInputService>();

            contract = inputService.CreateContract();
            contract.Enabled = true;
            contract.SubscribedTouchEvents = TouchStates.OnDoubleTap | TouchStates.OnDrag | TouchStates.OnTap;
            contract.TouchEventHandler += contract_TouchEventHandler;

            spriteBatch = spriteService.SpriteBatch;

            SelectionState = SelectionState.Selection;
            GameState = MultiplayerGameState.Connecting;
            GameCounter = 0;
            client = new Client();
            client.OnConnection += new EventHandler<ConnectionArgs>(ClientOnConnection);
            client.OnPacketRecieved += new EventHandler<PacketRecievedArgs>(ClientOnPacket);
            Packet ConnectionPacket = new Packet();
            ConnectionPacket.Write(provider.PGGI);
            ConnectionPacket.Write(provider.Token);
            client.Connect(new System.Net.DnsEndPoint(address, port), ConnectionPacket);
            Syncing = false;
            FramesToSpin = int.MaxValue;
            Manager = new MultiplayerGameManager();
            Content = new ContentManager(Atom.Shared.Globals.Engine, "Content");

            Fleet = Content.Load<Texture2D>("Graphics/Fleets/1");
        }
开发者ID:Nessphoro,项目名称:VelesConflict,代码行数:29,代码来源:MultiplayerBase.cs

示例2: TestMethod1

        public async Task TestMethod1()
        {
            var client = new Client("snpp.amsmsg.net", 444);

            var connected = await client.Connect();
            if (connected)
            {
                var resp = await client.Help();
                //await client.Pager("5551234");
                //var resp = await client.TwoWay();

                //var time = DateTime.Now.AddDays(3);
                //var resp = await client.HoldUntil(time, TimeZone.CurrentTimeZone.GetUtcOffset(time));

                await client.Quit();
            }


            //var resp1 = new Response("421 Gateway Service Unavailable\r\n");
            //var resp2 = new Response("999 Gateway Service Unavailable\r\n");
            //var resp3 = new Response("abc Gateway Service Unavailable\r\n");

            //var mal = resp3.Equals(ResponseCode.Malformed);

            var a = 3;
        }
开发者ID:PCFDev,项目名称:SNPPlib,代码行数:26,代码来源:UnitTest1.cs

示例3: Login

    public void Login()
    {
        playersToAdd = new List<Player>();
        allPlayers = new Dictionary<string, Player>();
        removeList = new List<Player>();

        client = new Client("http://188.231.242.101:3000");

        client.Opened += SocketOpened;
        client.Message += SocketMessage;
        client.SocketConnectionClosed += SocketConnectionClosed;
        client.Error += SocketError;

        client.Connect();

        game = new GameObject("game");
        player = new GameObject("player");
        player.transform.parent = game.transform;

        players = new GameObject("players");
        players.transform.parent = game.transform;

        StartCoroutine(updateCheck());

        canUpdate = true;
    }
开发者ID:Kiira02,项目名称:UnityProj,代码行数:26,代码来源:ClientInterface.cs

示例4: TestServiceAsyncCall

        public void TestServiceAsyncCall()
        {
            const ushort ServerPort = 13337;

            var endPoint = new HostEndPoint("localhost", ServerPort);

            // Start the server and setup our service.
            var server = new Server(endPoint);
            var serverThread = new Thread(Process);
            serverThread.Start(server);

            // Start the client and connect to the service.
            var client = new Client();
            var clientThread = new Thread(Process);
            clientThread.Start(client);

            var connectTask = client.Connect(endPoint);
            connectTask.Wait();
            Assert.IsTrue(connectTask.Result);

            var service = new ServiceTest();
            var serviceImpl = server.ServiceManager.ServiceManager.GetCreateImplementation<IServiceTest>(service);

            var serviceProxy = client.ServiceManager.GetService<IServiceTest>(new SessionRPCPeer(client.Session), serviceImpl.LocalId);
            var pingTask = serviceProxy.Ping();

            Assert.IsTrue(pingTask.Wait(1000));
            Assert.AreEqual("Pong", pingTask.Result);

            serverThread.Abort();
            clientThread.Abort();
         }
开发者ID:chartly,项目名称:flood,代码行数:32,代码来源:Network.cs

示例5: ClientMessagingSession

		internal ClientMessagingSession(Client connection, string host, int port)
		{
			this.connection = connection;
			connection.UniqueID = UniqueIDUnassigned;
			connection.DataReceived += DataReceived;
			connection.Connect(host, port);
		}
开发者ID:whztt07,项目名称:DeltaEngine,代码行数:7,代码来源:ClientMessagingSession.cs

示例6: Main

        static void Main(string[] args)
        {
            //Initialize the client with a 8kb receive/send buffer.
            Client = new Client(8192);

            //Add the packets to the serializer so we can properly send and receive messages.
            Client.AddTypesToSerializer(typeof(IPacket), new Type[]
            {
                typeof(Initialize),
                typeof(InitializeCommand),
                typeof(Message)
            });

            //Set up the events.
            Client.ClientState += ClientState;
            Client.ClientRead += ClientRead;

            //And finally, connect.
            Client.Connect("localhost", 31);

            while (true)
            {
                string message = Console.ReadLine();

                if (!string.IsNullOrWhiteSpace(message))
                    new Message(new Random().Next(int.MinValue, int.MaxValue), message).Execute(Client); //Last line wasn't empty, create a new Message with a random ID and message.
            }
        }
开发者ID:banksyhf,项目名称:Client-Server-Example,代码行数:28,代码来源:Program.cs

示例7: ConnectAndGetUsers

        private static void ConnectAndGetUsers(string address)
        {
            var username = System.Configuration.ConfigurationManager.AppSettings["VisualCronUserName"];
            var password = System.Configuration.ConfigurationManager.AppSettings["VisualCronPassword"];

            using (var client = new Client { LogToFile = false })
            {
                var connection = new Connection
                {
                    Address = address,
                    UseADLogon = true,
                    Port = 16444,
                    ConnectionType = Connection.ConnectionT.Remote,
                    UserName = username,
                    PassWord = password

                };

                try
                {
                    var server = client.Connect(connection);
                    EventHandler.UpdateMonitoringTimeMessage(server);
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Address: {0}, UseAdLogon: {1}, Port: {2}, ConnectionType: {3}, User: {4}, Password: {5}, Message: {6}, StackTrace: {7}",
                        connection.Address, connection.UseADLogon, connection.Port, connection.ConnectionType, connection.UserName, connection.PassWord, ex.Message, ex.StackTrace
                        ));
                }
            }
        }
开发者ID:danielharvell,项目名称:monitor-practice,代码行数:31,代码来源:VisualCronHandler.cs

示例8: StartClient

        static void StartClient(Client client)
        {
            client.Connect("test", "test");

            Thread.Sleep(5000);

            client.Send(new Packet("test pack yo."));
        }
开发者ID:JonHaywood,项目名称:Oberon,代码行数:8,代码来源:Program.cs

示例9: StartClient

 public static async Task StartClient()
 {
     BotBotController.client = new Client(Secrets.Token);
     await client.SendApiCall("reactions.list?token=" + Secrets.Token + "&full=true&count=100");
     HttpClient webClient = new HttpClient();
     Uri uri = new Uri(Client.BaseUrl + "rtm.start?token=" + Secrets.Token);
     HttpResponseMessage response = await webClient.GetAsync(uri);
     JObject responseObject = JObject.Parse(await response.Content.ReadAsStringAsync());
     await client.Connect(new Uri((string)responseObject["url"]));
 }
开发者ID:golf1052,项目名称:botbot,代码行数:10,代码来源:BotBotController.cs

示例10: Connect

        public void Connect()
        {
            Client c = new Client(new MockMqttBroker());
            c.ClientId = "clientId";

            Assert.IsFalse(c.IsConnected);
            c.Connect(new IPEndPoint(IPAddress.Loopback, 1883)).Wait();
            Assert.IsTrue(c.IsConnected);
            c.Disconnect(TimeSpan.FromSeconds(1));
            Assert.IsFalse(c.IsConnected);
        }
开发者ID:nivertech,项目名称:MQTT,代码行数:11,代码来源:ClientTests.cs

示例11: Awake

    void Awake()
    {
        client_ = new Client(serverUrl);

        client_.Opened  += SocketOpened;
        client_.Message += SocketMessage;
        client_.Error   += SocketError;
        client_.SocketConnectionClosed += SocketConnectionClosed;

        client_.Connect();
    }
开发者ID:hecomi,项目名称:NodejsUnity,代码行数:11,代码来源:SocketIO.cs

示例12: ConnectAndPing

        public void ConnectAndPing()
        {
            var server = new Server<Server.ChatService, IChatService>("localhost", "12345", "IntegrationTest");
            server.StartServer();

            var client = new Client<IChatService>("localhost", "12345", "IntegrationTest");
            client.Connect();
            client.GetService().Ping();
            client.Disconnect();

            server.StopServer();
        }
开发者ID:DeathlyEnterprises,项目名称:De.ChatService,代码行数:12,代码来源:ChatServiceIntegrationTests.cs

示例13: Start

    // Use this for initialization
    void Start()
    {
        client = new Client();
        client.Connect(Host, Port);

        client.OnConnectedCallback = () =>
        {
            Debug.Log("Connected!");

            var packet = client.Send(Commands.Type.JoinGame);
            packet.WriteString("Unity");
        };
    }
开发者ID:astrellon,项目名称:cotsb_unity_client,代码行数:14,代码来源:ClientEngine.cs

示例14: CreateClient

        public virtual void CreateClient(Action<BaseCommand> onCommand)
        {
            if (_client != null)
                return;

            _client = new Client(new ClientCallback(onCommand));

            try
            {
                _client.Connect();
            }
            catch (Exception)
            {
            }
        }
开发者ID:kobyb1988,项目名称:PhotoBox,代码行数:15,代码来源:ClientFactory.cs

示例15: Bot

        /// <summary>
        ///     
        /// </summary>
        /// <param name="host">IP of IRC command server</param>
        /// <param name="user">Username of the bot</param>
        public Bot(string host, string user)
        {
            LoadModules();

            _ircClient = new Client(host, new User(user));

            _ircClient.RawMessageSent += (sender, args) => Console.WriteLine(">> " + args.Message + "\n");
            _ircClient.RawMessageReceived += (sender, args) => Console.WriteLine("<< " + args.Message + "\n");

            _ircClient.SetHandler("001", OnServerReady);
            _ircClient.SetHandler("PRIVMSG", OnMessageReceived);

            if(!_ircClient.Connect()) {
                Console.WriteLine("Failed to connect");
            }
        }
开发者ID:Stenden-Projecten,项目名称:Botnet,代码行数:21,代码来源:Bot.cs


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