本文整理汇总了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");
}
示例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;
}
示例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;
}
示例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();
}
示例5: ClientMessagingSession
internal ClientMessagingSession(Client connection, string host, int port)
{
this.connection = connection;
connection.UniqueID = UniqueIDUnassigned;
connection.DataReceived += DataReceived;
connection.Connect(host, port);
}
示例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.
}
}
示例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
));
}
}
}
示例8: StartClient
static void StartClient(Client client)
{
client.Connect("test", "test");
Thread.Sleep(5000);
client.Send(new Packet("test pack yo."));
}
示例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"]));
}
示例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);
}
示例11: Awake
void Awake()
{
client_ = new Client(serverUrl);
client_.Opened += SocketOpened;
client_.Message += SocketMessage;
client_.Error += SocketError;
client_.SocketConnectionClosed += SocketConnectionClosed;
client_.Connect();
}
示例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();
}
示例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");
};
}
示例14: CreateClient
public virtual void CreateClient(Action<BaseCommand> onCommand)
{
if (_client != null)
return;
_client = new Client(new ClientCallback(onCommand));
try
{
_client.Connect();
}
catch (Exception)
{
}
}
示例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");
}
}