private void Deliver() { List <dynamic> list = new List <dynamic>(); var dbhelper = m_Node.GetDataHelper(); using (var cnn = dbhelper.OpenDatabase(m_MainCache)) { using (var cmd = cnn.CreateCommand()) { cmd.CommandText = "select * from tbl_round_state where backup_number = 0 "; using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { var item = new { server = reader["server_code"].ToString(), table = reader["table_code"].ToString(), label = reader["table_name"].ToString(), game = reader["game_type"].ToString(), shoe = reader["shoe_code"].ToString(), round = reader["round_number"].ToString(), state = reader["round_state"].ToString(), status = reader["round_state_text"].ToString(), players = reader["player_count"].ToString(), bet_countdown = reader["bet_time_countdown"].ToString(), game_countdown = reader["gaming_countdown"].ToString(), next_countdown = reader["next_game_countdown"].ToString(), starttime = Convert.ToDateTime(reader["round_start_time"]).ToString("yyyy-MM-dd HH:mm:ss"), updatetime = Convert.ToDateTime(reader["round_update_time"]).ToString("yyyy-MM-dd HH:mm:ss"), //history = reader["game_history"].ToString(), //remark = reader["game_remark"].ToString(), output = reader["game_output"].ToString(), result = reader["game_result"].ToString() }; list.Add(item); } } } } try { var clientMsg = new { msg = "table_info", tables = list }; var server = m_Node.GetPublicServer(); if (server != null && server.IsWorking()) { server.Broadcast(m_Node.GetJsonHelper().ToJsonString(clientMsg)); } } catch (Exception ex) { Console.WriteLine("FES Broadcast Error - " + ex.ToString()); } }
public void OnConnect(IWebSession session) { //Console.WriteLine(m_LocalNode.GetName() + " - OnConnect: " + session.GetRemoteAddress()); //System.Diagnostics.Debugger.Break(); //m_LocalNode.GetLogger().Info("OnClientConnect: " + session.GetRequestPath()); var clientMsg = new { msg = "client_info", client_id = session.GetRemoteAddress(), front_end = m_LocalNode.GetName(), action = "connect" }; var server = m_LocalNode.GetPublicServer(); if (server != null && server.IsWorking()) { session.Send(m_LocalNode.GetJsonHelper().ToJsonString(clientMsg)); } }
public void OnConnect(IWebSession session) { //Console.WriteLine(m_LocalNode.GetName() + " - OnConnect: " + session.GetRemoteAddress()); //m_LocalNode.GetLogger().Info("OnClientConnect: " + session.GetRequestPath()); if (m_Clients == null) { session.CloseConnection(); return; } var count = 0; var playerId = ""; var merchantCode = ""; var currencyCode = ""; var sessionId = ""; var parts = session.GetRequestPath().Split('/'); foreach (var part in parts) { if (part.Length <= 0) { continue; } count++; if (count == 1) { merchantCode = part; } if (count == 2) { currencyCode = part; } if (count == 3) { playerId = part; } if (count == 4) { sessionId = part; } if (count > 4) { break; } } var okay = false; var clientToken = ""; if (!String.IsNullOrEmpty(merchantCode) && !String.IsNullOrEmpty(currencyCode) && !String.IsNullOrEmpty(playerId) && !String.IsNullOrEmpty(sessionId)) { var dbhelper = m_LocalNode.GetDataHelper(); using (var cnn = dbhelper.OpenDatabase(m_MainCache)) { using (var cmd = cnn.CreateCommand()) { dbhelper.AddParam(cmd, "@session_id", sessionId); dbhelper.AddParam(cmd, "@merchant_code", merchantCode); dbhelper.AddParam(cmd, "@currency_code", currencyCode); dbhelper.AddParam(cmd, "@player_id", playerId); cmd.CommandText = " select * from tbl_player_session " + " where merchant_code = @merchant_code " + " and currency_code = @currency_code " + " and player_id = @player_id " + " and session_id = @session_id " ; using (var reader = cmd.ExecuteReader()) { if (reader.Read()) { okay = true; } } } if (okay) { clientToken = Guid.NewGuid().ToString(); using (var cmd = cnn.CreateCommand()) { dbhelper.AddParam(cmd, "@client_token", clientToken); dbhelper.AddParam(cmd, "@session_id", sessionId); dbhelper.AddParam(cmd, "@merchant_code", merchantCode); dbhelper.AddParam(cmd, "@currency_code", currencyCode); dbhelper.AddParam(cmd, "@player_id", playerId); cmd.CommandText = " update tbl_player_session " + " set client_token = @client_token, update_time = NOW() " + " where merchant_code = @merchant_code " + " and currency_code = @currency_code " + " and player_id = @player_id " + " and session_id = @session_id " ; okay = cmd.ExecuteNonQuery() > 0; } } } } //if (okay) m_LocalNode.GetLogger().Info("Client session is ok: " + sessionId); //else m_LocalNode.GetLogger().Info("Invalid session: " + sessionId); if (okay && m_Clients != null) { m_Clients.AddClient(session.GetRemoteAddress(), merchantCode, currencyCode, playerId, session); var clientMsg = new { msg = "client_info", client_id = session.GetRemoteAddress(), front_end = m_LocalNode.GetName(), client_token = clientToken, action = "connect" }; var server = m_LocalNode.GetPublicServer(); if (server != null && server.IsWorking()) { session.Send(m_LocalNode.GetJsonHelper().ToJsonString(clientMsg)); } } else { session.CloseConnection(); } }