public MerchantDataCache(IServerNode node)
        {
            m_Node   = node;
            m_Logger = m_Node.GetLogger();

            m_ServerName = m_Node.GetName();

            m_IsRunning = false;
        }
Esempio n. 2
0
        public TransactionCleaner(IServerNode node)
        {
            m_Node   = node;
            m_Logger = m_Node.GetLogger();

            m_ServerName = m_Node.GetName();

            m_IsWorking = false;
            m_IsRunning = false;
        }
Esempio n. 3
0
        public async Task JoinTable(RequestContext ctx)
        {
            //System.Diagnostics.Debugger.Break();

            string replyMsgName = "join_table_reply";

            string reqstr = ctx.Data.ToString();

            if (reqstr.Trim().Length <= 0)
            {
                await ctx.Session.Send(ctx.JsonHelper.ToJsonString(new
                {
                    msg           = replyMsgName,
                    error_code    = -1,
                    error_message = "Invalid request"
                }));

                return;
            }

            ctx.Logger.Info("Join Table - " + reqstr);

            dynamic req = ctx.JsonHelper.ToJsonObject(reqstr);

            string playerId     = req.player_id;
            string merchantCode = req.merchant_code;
            string currencyCode = req.currency_code;
            string tableCode    = req.table_code;

            string frontEnd = m_LocalNode.GetName();

            if (string.IsNullOrEmpty(frontEnd))
            {
                await ctx.Session.Send(ctx.JsonHelper.ToJsonString(new
                {
                    msg           = replyMsgName,
                    error_code    = -2,
                    error_message = "Service not available"
                }));

                return;
            }

            var remoteInfo = "";
            var rets       = await RemoteCaller.BroadcastCall(ctx.RemoteServices, "game-table", "find-game-table", tableCode);

            foreach (var item in rets)
            {
                if (item.Value == "ok")
                {
                    remoteInfo = item.Key;
                    break;
                }
            }
            if (string.IsNullOrEmpty(remoteInfo))
            {
                await ctx.Session.Send(ctx.JsonHelper.ToJsonString(new
                {
                    msg           = replyMsgName,
                    error_code    = -2,
                    error_message = "Service not available"
                }));

                return;
            }

            var tablereq = new
            {
                player_id     = playerId,
                merchant_code = merchantCode,
                currency_code = currencyCode,
                table_code    = tableCode,
                front_end     = frontEnd
            };

            var reply = await RemoteCaller.SpecifiedCall(ctx.RemoteServices, RemoteCaller.GetServerNameFromRemoteInfo(remoteInfo),
                                                         "game-table", "join-game-table", ctx.JsonHelper.ToJsonString(tablereq));

            if (string.IsNullOrEmpty(reply))
            {
                reply = ctx.JsonHelper.ToJsonString(new
                {
                    msg           = replyMsgName,
                    error_code    = -3,
                    error_message = "Failed to call join table function"
                });
            }
            else
            {
                dynamic ret = ctx.JsonHelper.ToJsonObject(reply);
                ret.msg = replyMsgName;
                reply   = ctx.JsonHelper.ToJsonString(ret);
            }

            await ctx.Session.Send(reply);
        }
 public void OnConnect(IWebSession session)
 {
     Console.WriteLine(m_LocalNode.GetName() + " - OnWebSocketConnect: " + session.GetRemoteAddress());
 }