예제 #1
0
        /**
         * 刷新金币
         *
         * @param session
         * @param doc
         */
        public void doorLoadG(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //
                XmlNode node = doc.SelectSingleNode("/msg/body");

                String strIpPort = session.getRemoteEndPoint().ToString();

                //
                IUserModel user = CLIENTAcceptor.getUser(strIpPort);

                //
                String caction = RCClientAction.loadG;

                String content = "<session>" + strIpPort + "</session><nick><![CDATA[" + user.getNickName() + "]]></nick>";

                //交给记录服务器处理
                RCConnector.Write(
                    XmlInstruction.DBfengBao(caction, content)
                    );

                //
                Log.WriteStrByTurn(SR.getRecordServer_displayName(), RCConnector.getRemoteEndPoint(), caction);
            }
            catch (Exception exd)
            {
                Log.WriteStrByException("GameLogicServer", "doorLoadG", exd.Message, exd.StackTrace);
            }
        }
        public ActionResult Unarchive(Int32 id)
        {
            Provider provider = db.Providers.Find(userContext.ItemId);

            if (provider == null)
            {
                return(HttpNotFound());
            }

            Location location = db.Locations.Find(id);

            if (location == null || location.ProviderId != userContext.ItemId ||
                location.RecordStatusId == (Int32)Constants.RecordStatus.Deleted)
            {
                return(HttpNotFound());
            }

            Location locDupPostcode = db.Locations.FirstOrDefault(x => x.RecordStatusId == (int)Constants.RecordStatus.Live && x.LocationId != location.LocationId && x.Address.Postcode == location.Address.Postcode && x.ProviderId == provider.ProviderId);

            if (locDupPostcode != null)
            {
                var message = AppGlobal.Language.GetText(this, "UnArchiveFailed", "Unable to unarchive location, there is already a location using this postcode.");
                SessionMessage.SetMessage(message, SessionMessageType.Danger, 2);
                return(RedirectToAction("Edit", "Location", new { Id = location.LocationId }));
            }

            location.Unarchive(db);
            db.SaveChanges();
            ShowGenericSavedMessage(true);
            return(RedirectToAction("Edit", "Location", new { Id = location.LocationId }));
        }
        public void doorHasRegOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                XmlNode node = doc.SelectSingleNode("/msg/body");

                String userStrIpPort = node.ChildNodes[0].InnerText;        //InnerText;

                AppSession userSession = getGameLogicServer().CLIENTAcceptor.getSession(userStrIpPort);

                //
                String saction = ServerAction.hasRegOK;

                String contentXml = "";

                //如果不在线则略过发送
                getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction, contentXml));

                //
                Log.WriteStrBySend(saction, userSession.getRemoteEndPoint().ToString());
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME(), "doorHasRegOK", exd.Message, exd.StackTrace);
            }
        }
예제 #4
0
        public void Listen()
        {
            _running     = true;
            _tcpListener = new TcpListener(IPAddress.Loopback, _port);
            _tcpListener.Start();

            while (_running)
            {
                TcpClient newClient = null;
                try
                {
                    newClient = _tcpListener.AcceptTcpClient();
                    var stream         = newClient.GetStream();
                    var sessionMessage = new SessionMessage();
                    sessionMessage.MergeDelimitedFrom(stream);
                    var sessionId = sessionMessage.SessionStart.SessionId;
                    _channelDictionary.AddOrUpdate(sessionId, new LocalChannel(newClient), (k, v) => v);
                    _newChannelEvent.Set();
                }
                catch (Exception e)
                {
                    newClient?.Dispose();

                    if (_running)
                    {
                        LogService.Log("Error on accepting new channel session", e);
                        throw;
                    }
                }
            }
            LogService.Log("XXX: Channel Server exiting...");
        }
예제 #5
0
        public SmqOppResult Opp(QueueMethod method, SessionMessage item)
        {
            //
            SmqOppResult ru = new SmqOppResult();

            if (QueueMethod.Add == method)
            {
                _smsgList.Enqueue(item);

                ru.oppSucess = true;
            }
            else if (QueueMethod.Shift == method && _smsgList.Count > 0)
            {
                ru.oppSucess = true;
                ru.item      = _smsgList.Dequeue();
            }
            else if (QueueMethod.Peek == method && _smsgList.Count > 0)
            {
                ru.oppSucess = true;
                ru.item      = _smsgList.Peek();
            }
            else if (QueueMethod.Count == method)
            {
                ru.oppSucess = true;
                ru.count     = _smsgList.Count;
            }

            return(ru);
        }
예제 #6
0
        /// <summary>Sends a message of the specified type, with the specified data to the specified player.</summary>
        /// <param name="player">The player to whom to send the packet.</param>
        /// <param name="type">The type of the message to send.</param>
        /// <param name="packet">The data to send.</param>
        private void SendTo(Player player, SessionMessage type, IWritablePacket packet)
        {
            if (!HasPlayer(player))
            {
                throw new ArgumentException("player");
            }
            try
            {
                using (var wrapper = new Packet())
                {
                    wrapper.Write((byte)type).Write(packet);
                    var written = _streams[player.Number].Write(wrapper);

                    // Statistics.
                    Info.PutOutgoingTraffic(
                        written,
                        type == SessionMessage.Data
                            ? TrafficTypes.Data
                            : TrafficTypes.Protocol);
                    Info.PutOutgoingPacketSize(written);
                    if (packet != null)
                    {
                        Info.PutOutgoingPacketCompression((packet.Length / (float)written) - 1f);
                    }
                }
            }
            catch (IOException ex)
            {
                // Client got disconnected.
                Logger.TraceException("Socket connection died.", ex);
                Remove(player.Number);
            }
        }
예제 #7
0
        override public void messageReceived(object session, object message)
        {
            try
            {
                AppSession s = (AppSession)session;

                XmlDocument doc = (XmlDocument)message;

                //<msg t="DBS"><body action=""></body></msg>
                string csAction = doc.DocumentElement.ChildNodes[0].Attributes["action"].Value;

                string strIpPort = s.RemoteEndPoint.ToString();

                //
                //Log.WriteStrByRecv(clientServerAction, strIpPort);

                //create item
                SessionMessage item = new SessionMessage(s, doc, false, strIpPort);

                //save
                RCLogicLPU.getInstance().getmsgList().Opp(QueueMethod.Add, item);

                //
                Log.WriteStrByRecv(csAction, strIpPort);
            }
            catch (Exception exd)
            {
                Log.WriteStrByException("RecordSocketDataHandler", "messageReceived", exd.Message);
            }
        }
        public ActionResult Create(AddEditApprenticeshipViewModel model)
        {
            model.ApprenticeshipId = 0;
            RemoveSpellCheckHTMLFromMarketingInformation(model);
            model.Validate(db, ModelState);
            if (ModelState.IsValid)
            {
                var apprenticeship = model.ToEntity(db);
                db.Apprenticeships.Add(apprenticeship);
                db.SaveChanges();

                List <String> messages = model.GetWarningMessages(db);
                if (messages.Count == 0)
                {
                    ShowGenericSavedMessage();
                }
                else
                {
                    // Add a blank entry at the beginning so the String.Join starts with <br /><br />
                    messages.Insert(0, "");
                    SessionMessage.SetMessage(AppGlobal.Language.GetText(this, "SaveSuccessfulWithWarnings", "Your changes were saved successfully with the following warnings:") + String.Join("<br /><br />", messages), SessionMessageType.Success);
                }

                return(Request.Form["Create"] != null
                    ? RedirectToAction("List")
                    : RedirectToAction("Create", "DeliveryLocation", new { id = apprenticeship.ApprenticeshipId }));
            }
            return(View(model));
        }
        /**
         *
         *
         *
         * @param session
         * @param doc
         * @param item
         */
        public void doorLoadDBTypeOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            //<msg t='DBS'><body action='loadDBTypeOK'>
            //<session>127.0.0.1:57107</session>
            //<DBTypeModel><mode>dz</mode><ver>X2.0</ver><sql>MySql</sql></DBTypeModel></body></msg>

            try{
                //trace(doc.ToString());

                getGameLogicServer().selectDB = DBTypeModel.fromXML(doc);


                XmlNode c = doc.SelectSingleNode("/msg/body/session");

                String userIpPort = c.InnerText;

                AppSession userSession = getGameLogicServer().netGetSession(userIpPort);

                String sAction = ServerAction.loadDBTypeOK;

                if (null != userSession)
                {
                    getGameLogicServer().Send(userSession, XmlInstruction.fengBao(sAction,
                                                                                  getGameLogicServer().selectDB.toXMLString(true)));

                    Log.WriteStrBySend(sAction, userSession.getRemoteEndPoint().ToString());
                }
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME(), "doorLoadDBTypeOK", exd.Message);
            }
        }
        public ActionResult Create(AddEditVenueModel model)
        {
            Provider provider = db.Providers.Find(userContext.ItemId);

            if (provider == null)
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)
            {
                CreateFromModel(model, provider.ProviderId);

                List <String> messages = model.GetWarningMessages();
                if (messages.Count == 0)
                {
                    ShowGenericSavedMessage();
                }
                else
                {
                    // Add a blank entry at the beginning so the String.Join starts with <br /><br />
                    messages.Insert(0, "");
                    SessionMessage.SetMessage(AppGlobal.Language.GetText(this, "SaveSuccessfulWithWarnings", "Your changes were saved successfully with the following warnings:") + String.Join("<br /><br />", messages), SessionMessageType.Success);
                }

                return(RedirectToAction("List"));
            }

            // Populate drop downs
            GetLookups(model);

            return(View(model));
        }
예제 #11
0
 /// <summary>Sends a message of the specified type, with the specified data to all players.</summary>
 /// <param name="type">The type of the message to send.</param>
 /// <param name="packet">The data to send.</param>
 protected override void Send(SessionMessage type, IWritablePacket packet = null)
 {
     foreach (var player in AllPlayers)
     {
         SendTo(player, type, packet);
     }
 }
        /**
         *
         *
         * @param session
         * @param doc
         * @param item
         */
        public void doorLoadTopListOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //<session>127.0.0.1:64828</session><chart total_add="0" total_sub="0"></chart>
                XmlNode node = doc.SelectSingleNode("/msg/body");

                String userStrIpPort = node.ChildNodes[0].InnerText; //InnerText;


                String topListXml = node.ChildNodes[1].OuterXml; //(new XMLOutputter()).outputString(node.ChildNodes()[1]);

                //
                String saction = ServerAction.topList;

                //回复
                //注意这里的session是上面的usersession,要判断是否还在线

                AppSession userSession = this.getGameLogicServer().CLIENTAcceptor.getSession(userStrIpPort);

                //
                this.getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction, topListXml));
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME(), "doorLoadTopListOK", exd.Message, exd.StackTrace);
            }
        }
예제 #13
0
        /// <summary>Sends a message of the specified type, with the specified data.</summary>
        /// <param name="type">The type of the message to send.</param>
        /// <param name="packet">The data to send.</param>
        protected override void Send(SessionMessage type, IWritablePacket packet = null)
        {
            if (ConnectionState != ClientState.Connected)
            {
                throw new InvalidOperationException("Not in a session.");
            }
            try
            {
                using (var wrapper = new Packet())
                {
                    wrapper.Write((byte)type).Write(packet);
                    var written = _stream.Write(wrapper);

                    // Statistics.
                    Info.PutOutgoingTraffic(
                        written,
                        type == SessionMessage.Data
                            ? TrafficTypes.Data
                            : TrafficTypes.Protocol);
                    Info.PutOutgoingPacketSize(written);
                    if (packet != null)
                    {
                        Info.PutOutgoingPacketCompression((packet.Length / (float)written) - 1f);
                    }
                }
            }
            catch (IOException ex)
            {
                Logger.TraceException("Socket connection died.", ex);
                Reset();
            }
        }
예제 #14
0
        /**
         *
         *
         * @param session
         * @param doc
         * @param item
         */
        public void doorHasReg(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                //
                XmlNode node = doc.SelectSingleNode("/msg/body");

                String strIpPort = session.getRemoteEndPoint().ToString();

                //
                String id_sql = node.InnerText;

                //
                String caction = RCClientAction.hasReg;

                String content = "<session>" + strIpPort + "</session><id_sql>" + id_sql + "</id_sql>";

                //交给记录服务器处理
                RCConnector.Write(XmlInstruction.DBfengBao(caction, content));

                //
                Log.WriteStrByTurn(SR.getRecordServer_displayName(), RCConnector.getRemoteEndPoint(), caction);
            }
            catch (Exception exd)
            {
                Log.WriteStrByException("GameLogicServer", "doorHasBeenReg", exd.Message, exd.StackTrace);
            }
        }
예제 #15
0
    public override void handleMessage(QTMessage message)
    {
        switch (message.messageType)
        {
        case QTMessage.type.READY:
            WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client;
            ReadyMessage         readyMessage   = (ReadyMessage)message;

            if (!qtRemoteClient.ready && readyMessage.state)
            {
                qtRemoteClient.ready = readyMessage.state;

                SessionMessage sessionMessage = new SessionMessage();
                sessionMessage.session = qtRemoteClient.session;
                qtRemoteClient.sendMessage(sessionMessage);

                QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Client(" + client.getIP() + ") is ready...");
                WorkerServerManager.instance.onClientReady(qtRemoteClient);
            }
            else
            {
                qtRemoteClient.ready = readyMessage.state;
            }
            break;
        }
    }
        public async Task <ActionResult> Edit(Int32 id, AddEditVenueModel model)
        {
            Provider provider = db.Providers.Find(userContext.ItemId);

            if (provider == null)
            {
                return(HttpNotFound());
            }

            if (model.VenueId != id)
            {
                return(HttpNotFound());
            }

            Venue venue = db.Venues.Find(id);

            if (venue == null)
            {
                return(HttpNotFound());
            }

            if (ModelState.IsValid)
            {
                venue = model.ToEntity(db);
                if (venue.ProviderId != userContext.ItemId)
                {
                    // User is trying to change the VenueId (or the context has changed)
                    return(HttpNotFound());
                }

                venue.ModifiedByUserId    = Permission.GetCurrentUserId();
                venue.ModifiedDateTimeUtc = DateTime.UtcNow;

                Address venueAddress = model.Address.ToEntity(db);

                db.Entry(venueAddress).State = EntityState.Modified;
                db.Entry(venue).State        = EntityState.Modified;
                await db.SaveChangesAsync();

                List <String> messages = model.GetWarningMessages();
                if (messages.Count == 0)
                {
                    ShowGenericSavedMessage();
                }
                else
                {
                    // Add a blank entry at the beginning so the String.Join starts with <br /><br />
                    messages.Insert(0, "");
                    SessionMessage.SetMessage(AppGlobal.Language.GetText(this, "SaveSuccessfulWithWarnings", "Your changes were saved successfully with the following warnings:") + String.Join("<br /><br />", messages), SessionMessageType.Success);
                }

                return(RedirectToAction("List"));
            }

            // Populate drop downs
            GetLookups(model);

            return(View(model));
        }
예제 #17
0
 /// <summary>
 /// Adds a stub to a list of stub
 /// </summary>
 /// <param name="stb"></param>
 public void SetSession(SessionMessage stb)
 {
     if (_stub != null)
     {
         throw new Exception("Unsupported -- only one stub for now");
     }
     _stub = stb;
 }
예제 #18
0
 public void UpdateSession(SessionMessage session)
 {
     this.SessionStart      = session.SessionStart;
     this.SessionExpire     = session.SessionExpire;
     this.Tariff            = session.Tariff;
     this.TotalPayment      = session.TotalPayment;
     this.IsInternetSession = session.IsInternetSession;
     this.IsPaused          = session.IsPaused;
 }
 public void SaveMessage(string deviceId, SessionMessage sessionMessage)
 {
     _clientsessionMessages.TryGetValue(deviceId, out ConcurrentQueue <SessionMessage> sessionMessages);
     _clientsessionMessages.AddOrUpdate(deviceId, sessionMessages, (id, message) =>
     {
         message.Enqueue(sessionMessage);
         return(sessionMessages);
     });
 }
예제 #20
0
 private void UnSubscribe(SessionMessage session_message)
 {
     string topic;
     Message message = session_message.message;
     if (message.TryGetValue("topic", out topic))
     {
         db.MergePath(topic).Subscribers.Remove(session_message.SessionId);
     }
     else throw new Exception("unsubscribe, topic missing");
 }
예제 #21
0
    public override void handleMessage(QTMessage message)
    {
        switch (message.messageType)
        {
        case QTMessage.type.SESSION:
            QTClient       qtClient       = (QTClient)client;
            SessionMessage sessionMessage = (SessionMessage)message;

            qtClient.session = sessionMessage.session;
            QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Recieved new session(" + sessionMessage.session.id + ")-");
            break;
        }
    }
예제 #22
0
        /// <summary>
        /// 从网络或本机数据库读取最新10记录
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="groupID"></param>
        /// <param name="sessionType"></param>
        /// <returns></returns>
        private List <SessionMessage> GetLastMessage(string userID, string groupID, string sessionType)
        {
            List <SessionMessage> rtn = new List <SessionMessage>();

            for (int i = 0; i < 10; i++)
            {
                SessionMessage itm = new SessionMessage();
                itm.Name = string.Format("M_{0}", i);
                rtn.Add(itm);
            }

            return(rtn);
        }
예제 #23
0
 private void Subscribe(SessionMessage request)
 {
     string topic;
     Message message = request.message;
     if (message.TryGetValue("topic", out topic))
     {
         LastValueDB fetch = db.MergePath(topic);
         fetch.Subscribers.Add(request.SessionId, true);
         SessionMessage session_message = new SessionMessage(request.SessionId, request.message);
         session_message.message["payload"] = fetch.Node.SerializeText();
         SendMessage(session_message);
     }
     else throw new Exception("subscribe, topic missing");
 }
예제 #24
0
        protected override void btn_OK_Click(object sender, RoutedEventArgs e)
        {
            var timeNow    = DateTime.Now;
            var newSession = new SessionMessage(timeNow, this.IsLimited ? timeNow.AddHours(this.Payment / this.CostPerHour) : timeNow.AddHours(23), this.SelectedTariff, this.IsInternetSession, this.Payment);

            foreach (Client client in ClientsList)
            {
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, (DispatcherOperationCallback) delegate(object o)
                {
                    client.ToCreate_Session(newSession, ToKillProcesses);
                    return(null);
                }, null);
            }
            this.Close();
        }
        public void doorRegOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                XmlNode node = doc.SelectSingleNode("/msg/body");

                String userStrIpPort = node.ChildNodes[0].InnerText;        //InnerText;

                String usersex   = node.ChildNodes[1].InnerText;
                String username  = node.ChildNodes[2].InnerText;
                String userpwd   = node.ChildNodes[3].InnerText;
                String useremail = node.ChildNodes[4].InnerText;         //这里的mail是email

                String bbs    = node.ChildNodes[5].InnerText;
                String sid    = node.ChildNodes[6].InnerText;
                int    id_sql = parseInt(node.ChildNodes[7].InnerText);

                //
                String saction = ServerAction.regOK;

                //回复
                //注意这里的session是上面的usersession,要判断是否还在线
                AppSession userSession = getGameLogicServer().CLIENTAcceptor.getSession(userStrIpPort);

                String contentXml = "<session>" + userStrIpPort + "</session><sex>" +
                                    usersex + "</sex><nick><![CDATA[" +
                                    username + "]]></nick><pwd><![CDATA[" +
                                    userpwd + "]]></pwd><bbs><![CDATA[" +
                                    bbs + "]]></bbs>" +
                                    //"<hico><![CDATA[" + hico + "]]></hico>" +
                                    //"<sid><![CDATA[" + sid + "]]></sid>" +
                                    "<id_sql>" +
                                    id_sql.ToString() + "</id_sql>" +
                                    "<mail>" +
                                    useremail + "</mail>";


                //如果不在线则略过发送
                getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction, contentXml));

                //
                Log.WriteStrBySend(saction, userSession.getRemoteEndPoint().ToString());
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME(), "doorRegOK", exd.Message);
            }
        }
예제 #26
0
        public void doorHeartBeat(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                if (CLIENTAcceptor.hasUser(session.getRemoteEndPoint().ToString()))
                {
                    IUserModel curUser = CLIENTAcceptor.getUser(session.getRemoteEndPoint().ToString());

                    curUser.setHeartTime(DateTime.Now.Minute);            //LocalTime.now().getMinute());
                }
            }
            catch (Exception exd)
            {
                Log.WriteStrByException("GameLogicServer", "doorHeartBeat", exd.Message, exd.StackTrace);
            }
        }
        public void doorLoadGOK(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                XmlNode node = doc.SelectSingleNode("/msg/body");

                String userStrIpPort = node.ChildNodes[0].InnerText; //InnerText;

                String g = node.ChildNodes[1].InnerText;             //InnerText;

                String id_sql = node.ChildNodes[1].Attributes["id_sql"].Value;
                //
                String saction = ServerAction.gOK;

                //回复
                //注意这里的session是上面的usersession,要判断是否还在线
                AppSession userSession = getGameLogicServer().netGetSession(userStrIpPort);

                //如果不在线则略过发送
                if (null != userSession)
                {
                    IUserModel u = getGameLogicServer().CLIENTAcceptor.getUser(userStrIpPort);

                    //以免引发不必要的异常,方便测试
                    if (!(g == ""))
                    {
                        u.setG(parseInt(g));
                    }

                    getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction,
                                                                                  "<g " + "id_sql='" + id_sql + "'" + ">" + g + "</g>"));

                    //
                    Log.WriteStrBySend(saction, userSession.getRemoteEndPoint().ToString());
                }
                else
                {
                    Log.WriteStrBySendFailed(saction, userSession.getRemoteEndPoint().ToString());
                }         //end if
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME(), "doorLoadGOK", exd.Message);
            }
        }
        public void doorNeedProof(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                String saction = ServerAction.hasProof;

                //回复
                session.Write(
                    XmlInstruction.DBfengBao(saction, "<proof>" + getGameLogicServer().RCConnector.getProof() + "</proof>")
                    );

                //
                Log.WriteStrBySend(saction, session.getRemoteEndPoint().ToString());
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME(), "doorNeedProof", exd.Message, exd.StackTrace);
            }
        }
예제 #29
0
        /**
         * 注册
         *
         * @param session
         * @param doc
         */
        public void doorReg(AppSession session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                XmlNode node = doc.SelectSingleNode("/msg/body");

                //
                String usersex   = node.ChildNodes[0].InnerText;
                String username  = node.ChildNodes[1].InnerText;
                String userpwd   = node.ChildNodes[2].InnerText;
                String useremail = node.ChildNodes[3].InnerText;

                String bbs = node.ChildNodes[4].InnerText;

                String sessionId = node.ChildNodes[5].InnerText;
                String id_sql    = node.ChildNodes[6].InnerText;

                //需校验,其中email是从网页输出的,用户一般改不了,但用户名可改
                String caction = RCClientAction.reg;

                String contentXml = "<session>" + session.getRemoteEndPoint().ToString() + "</session><sex>" +
                                    usersex + "</sex><nick><![CDATA[" +
                                    username + "]]></nick><pwd><![CDATA[" +
                                    userpwd + "]]></pwd><mail><![CDATA[" +
                                    useremail + "]]></mail><bbs><![CDATA[" +
                                    bbs + "]]></bbs><sid>" +
                                    sessionId + "</sid><id_sql>" +
                                    id_sql + "</id_sql>";


                //注册前先到记录服务器验证一下
                RCConnector.Write(
                    XmlInstruction.DBfengBao(caction, contentXml)
                    );

                //
                Log.WriteStrByTurn(SR.getRecordServer_displayName(), caction, RCConnector.getRemoteEndPoint());
            }
            catch (Exception exd)
            {
                Log.WriteStrByException("GameLogicServer", "doorReg", exd.Message);
            }
        }
예제 #30
0
 private void Publish(SessionMessage request)
 {
     string topic, payload;
     Message message = request.message;
     if (message.TryGetValue("topic", out topic) && message.TryGetValue("payload", out payload))
     {
         Message node = new Message(payload);
         LastValueDB child = db.Update(topic, node);
         List<Guid> remove = new List<Guid>();
         foreach (Guid session_id in child.Subscribers.Keys)
         {
             SessionMessage response = new SessionMessage(session_id, request.message);
             if (!SendMessage(response))
                 remove.Add(session_id);
         }
         foreach (Guid guid in remove)
             child.Subscribers.Remove(guid);
     }
     else throw new Exception("publish, topic or payload missing");
 }
예제 #31
0
        public void ToCreate_Session(bool isSentFromClient, SessionMessage newSession, Boolean toKillProcesses)
        {
            this.SessionExpire     = newSession.SessionExpire;
            this.SessionStart      = newSession.SessionStart;
            this.Tariff            = newSession.Tariff;
            this.IsInternetSession = newSession.IsInternetSession;
            this.IsPaused          = newSession.IsPaused;
            this.TotalPayment      = newSession.TotalPayment;

            this.ToStartSession(); //START SESSION

            NotifyPropertyChanged("StartSessionTime");
            NotifyPropertyChanged("EndSessionTime");
            NotifyPropertyChanged("RemainingTime");

            if (!isSentFromClient)
            {
                SendUpdateMessageToClient(toKillProcesses);
            }
        }
예제 #32
0
        public static List <SessionsEntity> getListSession(long numberRecords)
        {
            Dictionary <string, object> listParameter = new Dictionary <string, object>();

            //meetingEntity
            listParameter.Add("meetingEntity", "");
            //activity
            listParameter.Add("activity", "");
            //meetingDay
            listParameter.Add("meetingDay", "");
            //page
            listParameter.Add("page", "1");
            //size
            listParameter.Add("size", String.Format("{0}", numberRecords));

            string result = SendGetRequest(AppsSettings.GetInstance().ApiUrl + "/sessions/findByUserPermit", listParameter);

            if (result.Equals(""))
            {
                return(new List <SessionsEntity>());
            }
            else
            {
                try
                {
                    SessionMessage sessionMsg = JsonConvert.DeserializeObject <SessionMessage>(result);
                    if (sessionMsg != null)
                    {
                        return(sessionMsg.data.listSession);
                    }
                    else
                    {
                        return(new List <SessionsEntity>());
                    }
                } catch (Exception e) {
                    Debug.WriteLine(e);
                    return(new List <SessionsEntity>());
                }
            }
        }
        public void doorRegKO(SocketConnector session, XmlDocument doc, SessionMessage item)
        {
            try
            {
                XmlNode node = doc.SelectSingleNode("/msg/body");

                String userStrIpPort = node.ChildNodes[0].InnerText;

                String status = node.ChildNodes[1].InnerText;

                String param = node.ChildNodes[2].InnerText;

                //
                String saction = ServerAction.regKO;

                //回复
                //注意这里的session是上面的usersession,要判断是否还在线
                AppSession userSession = getGameLogicServer().CLIENTAcceptor.getSession(userStrIpPort);

                //如果不在线则略过发送
                if (null != userSession)
                {
                    //if (userSession.getConnected())
                    //{
                    getGameLogicServer().Send(userSession, XmlInstruction.fengBao(saction, "<status>" + status + "</status><p>" + param + "</p>"));

                    //
                    Log.WriteStrBySend(saction, userSession.getRemoteEndPoint().ToString());
                    //} //end if
                }
                else
                {
                    Log.WriteStrBySendFailed(saction, userSession.getRemoteEndPoint().ToString());
                }         //end if
            }
            catch (Exception exd)
            {
                Log.WriteStrByException(CLASS_NAME(), "doorRegKO", exd.Message);
            }
        }
예제 #34
0
 public void OnMessage(SessionMessage request)
 {
     string command;
     Message message = request.message;
     if (message.TryGetValue("command", out command))
     {
         switch (command)
         {
             case "publish":
                 Publish(request);
                 break;
             case "subscribe":
                 Subscribe(request);
                 break;
             case "unsubscribe":
                 UnSubscribe(request);
                 break;
             default:
                 throw new Exception("unknown command: " + command);
         }
     }
 }
예제 #35
0
 private void OnMessage(SessionMessage session_message)
 {
     topic_server.OnMessage(session_message);
 }
예제 #36
0
 private bool SendMessage(SessionMessage message)
 {
     foreach (IMessageServer iMessageServer in message_servers)
         if(iMessageServer.SendMessage(message))
             return true;
     return false;
 }
 private void MessageWaiting(SessionMessage session_message)
 {
     message_server.SendMessage(session_message);
 }
예제 #38
0
 bool IMessageServer.SendMessage(SessionMessage session_message)
 {
     return session_manager.SendMessage(session_message);
 }