public static void WebStart(HttpConfiguration config) { SignumServer.Start(config, typeof(Global).Assembly); AuthServer.Start(config, () => Starter.Configuration.Value.AuthTokens, "IMPORTANT SECRET FROM Southwind. CHANGE THIS STRING!!!"); CacheServer.Start(config); FilesServer.Start(config); UserQueryServer.Start(config); DashboardServer.Start(config); WordServer.Start(config); ExcelServer.Start(config); ChartServer.Start(config); MapServer.Start(config); TranslationServer.Start(config, new AlreadyTranslatedTranslator(new BingTranslator())); SchedulerServer.Start(config); ProcessServer.Start(config); DisconnectedServer.Start(config); MailingServer.Start(config); ProfilerServer.Start(config); DiffLogServer.Start(config); OmniboxServer.Start(config, new EntityOmniboxResultGenenerator(), new DynamicQueryOmniboxResultGenerator(), new ChartOmniboxResultGenerator(), new DashboardOmniboxResultGenerator(DashboardLogic.Autocomplete), new UserQueryOmniboxResultGenerator(UserQueryLogic.Autocomplete), new UserChartOmniboxResultGenerator(UserChartLogic.Autocomplete), new MapOmniboxResultGenerator(type => OperationLogic.TypeOperations(type).Any()), new ReactSpecialOmniboxGenerator() //new HelpModuleOmniboxResultGenerator(), ); //Omnibox }
private void StartClient() { try { _client = new Tcp_Client(ServerIpAddress.ToString(), ServerPort, ServerConnected, ServerDisconnected, MessageReceived, false); _isServerConnected = true; MessageModel message = new MessageModel(); message.Type = Type.ClientLogon; message.Message = string.Empty; message.PcName = Environment.MachineName; string json = JsonConvert.SerializeObject(message); if (_key == null) { _client.Send(Encoding.UTF8.GetBytes(json)); } else { _client.Send(ExtensionMethods.Encrypt(json, _key)); } } catch { _isServerConnected = false; DisconnectedServer?.Invoke("No server connection"); } }
private bool MessageReceived(byte[] data) { string receiveData = string.Empty; if (_key == null) { receiveData = Encoding.UTF8.GetString(data); } else { receiveData = Encoding.UTF8.GetString(ExtensionMethods.Decrypt(Convert.ToBase64String(data), _key)); } var message = JsonConvert.DeserializeObject <MessageModel>(receiveData); if (message == null) { return(true); } LocalInfo info; info.ipAddress = _client.LocalAddress; info.localEndPoint = Convert.ToInt32(_client.LocalPort); info.pcName = Environment.MachineName; if (message.Type == Type.AcceptLogon) { _isServerConnected = true; ConnectedServer?.Invoke(info); } if (message.Type == Type.Disconnect) { _client.Dispose(); _client = null; _flagOfThreadsBreak = true; _isServerConnected = false; DisconnectedServer?.Invoke("Connection disconnected by Server"); } if (message.Type == Type.Blocked) { _client.Dispose(); _client = null; _isServerConnected = false; DisconnectedServer?.Invoke("It does not connect to the server because it is a blocked IP."); } if (message.Type == Type.Message) { ReceivedMessageFromServer?.Invoke(message.Message); } return(true); }
public void DisconnectServer() { _flagOfThreadsBreak = true; if (_client != null) { _client.Dispose(); _client = null; _isServerConnected = false; DisconnectedServer?.Invoke("No server connection."); } }