public EQItem() { InitializeComponent(); CheckForIllegalCrossThreadCalls = false; TcpController = new TcpController(this); this.toolTip1.SetToolTip(this.EQMessage, EQMessage.Text); }
// Use this for initialization void Awake() { serverIP = Data.ip; instance = this; TcpClient tcpClient = new TcpClient(); TcpConnectedClient connectedClient = new TcpConnectedClient(tcpClient); tcpClient.BeginConnect(serverIP, Data.port, ar => connectedClient.EndConnect(ar), null); LoginController.generatePlayer(Data.login); }
public async Task TcpController_GetAll(IEnumerable <TcpConnectionData> connData) { var tcpSrv = new Mock <ITcpService>(); tcpSrv.Setup(t => t.GetAll()).ReturnsAsync(connData); var ctrl = new TcpController(tcpSrv.Object); var response = await ctrl.GetAll(); var content = response.ShouldBeOfType <OkObjectResult>(); (content.Value as IEnumerable <TcpConnectionData>).ShouldBe(connData); }
public async Task TcpController_GetById(TcpConnectionData connData, Type expResponseType) { var tcpSrv = new Mock <ITcpService>(); tcpSrv.Setup(t => t.GetById(It.IsAny <string>())).ReturnsAsync(connData); var ctrl = new TcpController(tcpSrv.Object); var response = await ctrl.GetById("some-id"); response.ShouldBeOfType(expResponseType); var content = (response as ObjectResult); (content.Value as TcpConnectionData).ShouldBe(connData); }
void OnRead(IAsyncResult ar) { int length = stream.EndRead(ar); if (length <= 0) { TcpController.instance.OnDisconnect(this); return; } string newMsg = Encoding.UTF8.GetString(readBuf, 0, length); FastDataObject fdo = new FastDataObject(newMsg); String action = fdo.getParameter("action"); Packet packet = PacketManager.getPacket(action); Data.Players.Add(new Player()); if (TcpController.instance.isServer) TcpController.BroadcastMessage(newMsg); stream.BeginRead(readBuf, 0, readBuf.Length, OnRead, null); }
static void Main(string[] args) { LoggerFactory.SetLogger(new ConsoleLogger()); var logger = LoggerFactory.GetLogger(); if (args.Length == 0) { logger.Print(0, MessageType.Error, "No configuration file"); return; } Configuration configuration = null; try { var contents = File.ReadAllText(args[0]); configuration = contents.FromJson <Configuration>(); } catch (Exception ex) { logger.Print(0, MessageType.Error, $"Error on reading config [{args[0]}] file"); logger.Print(0, MessageType.Error, ex.Message); return; } if (string.IsNullOrWhiteSpace(configuration?.HttpBaseUrl)) { logger.Print(0, MessageType.Error, $"http_base_url required"); return; } logger.Print(0, MessageType.Info, "configuration successfully loaded"); logger.Print(0, MessageType.Info, $"http_base_url loaded [{configuration.HttpBaseUrl}]"); if (string.IsNullOrWhiteSpace(configuration.ImapAddress)) { configuration.ImapAddress = "127.0.0.1"; logger.Print(0, MessageType.Info, $"imap_address using default value [{configuration.ImapAddress}]"); } else { logger.Print(0, MessageType.Info, $"imap_address loaded [{configuration.ImapAddress}]"); } var entityFactory = new HttpEntityProviderFactory(configuration.HttpBaseUrl); var tcpController = new TcpController(configuration.ImapAddress, 143, entityFactory); try { tcpController.Listen(); } finally { tcpController.Dispose(); } }
internal ToolsetManager() { TCP = new TcpController(); }