/// <summary> /// Main constructor. Sets up CommandManager /// </summary> public Messenger() { TCPClient = new TcpNETClient(new ParamsTcpClient() { Uri = Server, Port = Port, IsSSL = false }); TCPClient.MessageEvent += TCPClient_MessageEvent; TCPClient.ConnectAsync().GetAwaiter().GetResult(); CommandManager = new CommandManager(TCPClient); }
public TcpClientAC(string accessToken, string uri = "connect.allie.chat", int port = 7625, bool isSSL = true) { _accessToken = accessToken; _connectUri = uri; _connectPort = port; _tcpClient = new TcpNETClient(new ParamsTcpClient { EndOfLineCharacters = "\r\n", IsSSL = isSSL, Port = _connectPort, Uri = _connectUri }, _accessToken); _tcpClient.ConnectionEvent += OnConnectionEvent; _tcpClient.MessageEvent += OnMessageEvent; _tcpClient.ErrorEvent += OnErrorEvent; }
public NTierClient(IParamsNTierClient parameters, string oauthToken = "") { _parameters = parameters; _client = string.IsNullOrWhiteSpace(oauthToken) ? new TcpNETClient(new ParamsTcpClient { EndOfLineCharacters = "\r\n", Port = _parameters.Port, Uri = _parameters.Uri, IsSSL = _parameters.IsSSL }) : new TcpNETClient(new ParamsTcpClient { EndOfLineCharacters = "\r\n", Port = _parameters.Port, Uri = _parameters.Uri, IsSSL = _parameters.IsSSL }, oauthToken: oauthToken); _client.ConnectionEvent += OnConnectionEvent; _client.ErrorEvent += OnErrorEvent; _client.MessageEvent += OnMessageEvent; }
static async Task Main(string[] args) { _client = new TcpNETClient(new ParamsTcpClient { EndOfLineCharacters = "\r\n", Port = 8989, Uri = "localhost", IsSSL = false, }, oauthToken: "faketoken"); _client.MessageEvent += OnMessageEvent; _client.ConnectionEvent += OnConnectionEvent; _client.ErrorEvent += OnErrorEvent; await _client.ConnectAsync(); await _client.SendToServerRawAsync("Hello world"); while (true) { var line = Console.ReadLine(); await _client.SendToServerAsync(line); } }
/// <summary> /// The CommandManager constructor. /// Should be initialized only one time! /// </summary> /// <param name="tcp">The TCP client.</param> public CommandManager(ITcpNETClient tcp) { tcpClient = tcp; tcpClient.MessageEvent += TcpClient_MessageEvent;; }