コード例 #1
0
    /// <summary>
    /// 發信給設定的信箱 By 訊息
    /// </summary>
    /// <param name="messageVO"></param>
    public void SendMail_ToContactor_ByMessage(MessageVO messageVO)
    {
        try
        {
            string classify = "聯絡我們收件者";
            IList <ItemParamVO> contactorList = m_SystemService.GetAllItemParamByNoDel(classify);

            if (contactorList != null && contactorList.Count > 0)
            {
                SystemParamVO mailVO      = m_SystemService.GetSystemParamByRoot();
                MailService   mailService = new MailService(mailVO.MailSmtp, int.Parse(mailVO.MailPort), mailVO.EnableSSL, mailVO.Account, mailVO.Password);

                StringBuilder sbMailList = new StringBuilder();
                foreach (ItemParamVO contactor in contactorList)
                {
                    sbMailList.Append(string.Format("{0};", contactor.Value));
                }

                string mailTitle   = string.Format("收到一封由【{0}】從網站發出的線上諮詢。", messageVO.CreateName);
                string mailContent = GenMailContent(messageVO);

                mailService.SendMail(mailVO.SendEmail, sbMailList.ToString(), mailTitle, mailContent);
            }
        }
        catch (Exception ex)
        {
            m_Log.Error(ex);
        }
    }
コード例 #2
0
        private void SendToClient(Client client, string message)
        {
            if (client == null)
            {
                _log.Information("Not possible, client is null");
                return;
            }

            _log.Information("Sending reply to client: {0}", client.NickName);

            MessageVO msg = new MessageVO();

            msg.CreateMessageToBeSendByServer(message);

            // Create reply
            var byteReply = msg.ConvertMessageToBeSendToBytes();

            // Listen for more incoming messages
            try
            {
                client.Socket.BeginSend(byteReply, 0, byteReply.Length, SocketFlags.None, new AsyncCallback(SendReplyCallback), client);
            }
            catch (SocketException)
            {
                // Client was forcebly closed on the client side
                CloseClient(client);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #3
0
ファイル: SceneController.cs プロジェクト: harryqk/Newbie
    private void Update()
    {
        if (NetScene.getInstance().queMes.Count > 0)
        {
            MessageVO vo = NetScene.getInstance().queMes.Dequeue();
            Serializer.Deserialize(vo.protocol, vo.data);


            if (NetScene.getInstance().frame % 350 == 0)
            {
                ModelFactory.getStance().spawn();
                txtLog.text = ModelFactory.getStance().curSpawn + "/" + ModelFactory.maxSpawn;
                //txtLog.text = Random.Range(1, 100).ToString();
            }
        }

        if (NetMgr.GetInstance().client.GetReadMsg() != null &&
            NetMgr.GetInstance().client.GetReadMsg().Count > 0)
        {
            string s = NetMgr.GetInstance().client.GetReadMsg().Dequeue();
            txtLog.text = s;
            Debug.Log(s);
        }

        if (NetMgr.GetInstance().client.GetLog() != null &&
            NetMgr.GetInstance().client.GetLog().Count > 0)
        {
            string s = NetMgr.GetInstance().client.GetLog().Dequeue();
            Debug.Log(s);
        }
        keyboardMove();
        shoot();
    }
コード例 #4
0
 public ForumMessage(MessageVO messageVO, Guid account, Guid forumId)
 {
     this._messageVO    = messageVO;
     this._account      = account;
     this._creationDate = DateTime.Now;
     this._modifiedDate = this._creationDate;
     this._forum        = forumId;
     //this._forumThreadId = threadId;
     this._messageId = Guid.NewGuid();
 }
コード例 #5
0
        /// <summary>
        /// 回复帖子的回复
        /// </summary>
        /// <param name="model">回复模型</param>
        public void ReplyToRepliedMessage(ReplyRepliedMsgModel model)
        {
            //IForumThreadRepository forumThreadRep = FBS.Factory.Factory<IForumThreadRepository>.GetConcrete();
            //IAccountRepository accountRep = FBS.Factory.Factory<IAccountRepository>.GetConcrete();
            //IForumsRepository forumsRep = FBS.Factory.Factory<IForumsRepository>.GetConcrete();
            //IForumMessageRepository msgRep = FBS.Factory.Factory<IForumMessageRepository>.GetConcrete();

            IForumThreadRepository threadRep = Factory.Factory <IForumThreadRepository> .GetConcrete();

            IRepository <ForumThread> threadWriteRep = Factory.Factory <IRepository <ForumThread> > .GetConcrete <ForumThread>();

            IRepository <ForumMessageReply> msgRep = Factory.Factory <IRepository <ForumMessageReply> > .GetConcrete <ForumMessageReply>();

            IRepository <Forum> forumRep = Factory.Factory <IRepository <Forum> > .GetConcrete <Forum>();

            IRepository <Account> accountRep = Factory.Factory <IRepository <Account> > .GetConcrete <Account>();

            //获取欲回复的回复
            ForumMessageReply readyToReply = msgRep.GetByKey(model.ReadyToReplyMessageID);
            ForumThread       thread       = threadRep.GetByKey(model.ThreadID);
            Forum             forum        = forumRep.GetByKey(thread.ForumID);
            //板块
            //Forum forum = forumsRep.GetByKey(readyToReply.Forum);

            //消息对象
            MessageVO mVO = new MessageVO();

            switch (model.ReplyType)
            {
            case ReplyType.Quote:
                mVO.Body = "<div class=\"quote\">" + "@<a href='" + FBS.Utils.UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, readyToReply.Account.ToString()) + "' target='_blank'>" + accountRep.GetByKey(readyToReply.Account).UserName + "</a><br />" + readyToReply.MessageVO.Body + "</div>" + model.Body;
                break;

            default:
                mVO.Body = "<div class=\"reply\">" + "@<a href='" + FBS.Utils.UrlFactory.CreateUrl(UrlFactory.PageName.UserHome, readyToReply.Account.ToString()) + "' target='_blank'>" + accountRep.GetByKey(readyToReply.Account).UserName + "</a><br />" + readyToReply.MessageVO.Body + "</div>" + model.Body;
                break;
            }

            ForumMessageReply newReply = new ForumMessageReply(mVO, model.User.UserID, forum.Id, model.ReadyToReplyMessageID, model.ThreadID);

            //更新"吧"的帖子数
            forum.AddNewMessage(newReply);
            forumRep.Update(forum);
            forumRep.PersistAll();

            //更新主题的最后更新时间
            thread.ModifiedDate = newReply.CreationDate;
            thread.AddMessageCount();
            threadWriteRep.Update(thread);
            threadWriteRep.PersistAll();

            //向库中增加回帖
            msgRep.Add(newReply);
            msgRep.PersistAll();
        }
コード例 #6
0
        private string GenMailContent(MessageVO messageVO)
        {
            StringBuilder sbContent = new StringBuilder();

            sbContent.Append(string.Format("時  間:{0}<br />", messageVO.CreatedDate.Value.ToString()));
            sbContent.Append(string.Format("姓  名:{0}<br />", messageVO.CreateName));
            sbContent.Append(string.Format("電  話:{0}<br />", messageVO.Phone));
            sbContent.Append(string.Format("手  機:{0}<br />", messageVO.Mobile));
            sbContent.Append(string.Format("傳  真:{0}<br />", messageVO.Fax));
            sbContent.Append(string.Format("電子信箱:{0}<br />", messageVO.EMail));
            sbContent.Append(string.Format("意  見:{0}<br />", messageVO.Content.Replace("\n", "<br />")));

            return(sbContent.ToString());
        }
コード例 #7
0
    private string GenMailContent(MessageVO messageVO)
    {
        StringBuilder sbContent = new StringBuilder();

        sbContent.Append(string.Format("建立時間:{0}<br />", messageVO.CreatedDate.Value.ToString()));
        sbContent.Append(string.Format("預約日期:{0}<br />", messageVO.ReservationDate.Value.ToString("yyyy/MM/dd")));
        sbContent.Append(string.Format("預約時段:{0}<br />", messageVO.ReservationPeriod));
        sbContent.Append(string.Format("姓  名:{0}<br />", messageVO.CreateName));
        sbContent.Append(string.Format("連絡電話:{0}<br />", messageVO.Phone));
        sbContent.Append(string.Format("電子信箱:{0}<br />", messageVO.EMail));
        sbContent.Append(string.Format("預約內容:<br />{0}<br />", messageVO.Content.Replace("\n", "<br />")));

        return(sbContent.ToString());
    }
コード例 #8
0
        private void AppendMessage(MessageVO message)
        {
            if (message.FromUser.Id == toUser.Id)
            {
                ConversationRTB.SelectionColor = toUserColor;
            }
            else
            {
                ConversationRTB.SelectionColor = currentUserColor;
            }

            ConversationRTB.SelectedText = message.FromUser + ": " + message.Body + "\n";
            ConversationRTB.AppendText(ConversationRTB.SelectedText);
        }
コード例 #9
0
        private void AddMessage()
        {
            string text = TypingTB.Text;


            if (text != String.Empty)
            {
                MessageVO message = new MessageVO();
                message.Body     = text;
                message.FromUser = ConfigurationManager.currUser;
                message.ToUser   = toUser;
                messageManager.Insert(message);
                AppendMessage(message);
            }
        }
コード例 #10
0
 public void UpdateByNetWork()
 {
     while (true)
     {
         if (NetMgr.GetInstance().client.GetMoveMsg() != null &&
             NetMgr.GetInstance().client.GetMoveMsg().Count > 0)
         {
             MessageVO data  = new MessageVO();
             MessageVO data1 = NetMgr.GetInstance().client.GetMoveMsg().Dequeue();
             data.protocol = data1.protocol;
             data.data     = data1.data;
             Serializer.SynDeserialize(data1.protocol, data1.data);
             queMes.Enqueue(data);
             frame++;
         }
     }
 }
コード例 #11
0
        /// <summary>
        /// 创建一个主题
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public void CreateThread(NewThreadModel model)
        {
            //创建主题仓储
            //IForumThreadRepository forumThreadRep = FBS.Factory.Factory<IForumThreadRepository>.GetConcrete();
            //IAccountRepository accountRep = FBS.Factory.Factory<IAccountRepository>.GetConcrete();
            //IForumsRepository forumsRep = FBS.Factory.Factory<IForumsRepository>.GetConcrete();

            IRepository <ForumThread> threadRep = Factory.Factory <IRepository <ForumThread> > .GetConcrete <ForumThread>();

            IRepository <ThreadRootMessage> msgRep = Factory.Factory <IRepository <ThreadRootMessage> > .GetConcrete <ThreadRootMessage>();

            //Account creater = null;
            ForumThread       topic   = null;
            ThreadRootMessage rootMsg = null;

            //帖子内容对象
            MessageVO messageVO = new MessageVO();

            messageVO.Body    = model.Body;
            messageVO.Subject = model.Title;

            try
            {
                //creater = accountRep.GetByKey(model.AccountID);

                rootMsg = new ThreadRootMessage(messageVO, model.AccountID, model.ForumID);
                topic   = new ForumThread(rootMsg, model.ForumID);


                //topic.RootMessage = rootMsg;

                threadRep.Add(topic);
                msgRep.Add(rootMsg);

                threadRep.PersistAll();
                msgRep.PersistAll();

                //forumThreadRep.Add(topic);
                //forumThreadRep.PersistAll();
            }
            catch
            {
                throw new AddForumThreadException("添加主题至仓储时异常");
            }
        }
コード例 #12
0
    public void Receive()
    {
        while (socketClient != null &&
               socketClient.Connected == true)
        {
            int len = NetUtil.ReadInt(socketClient, bufferForInt);
            if (len > 0)
            {
                int protocol = NetUtil.ReadInt(socketClient, bufferForInt);
                if (protocol > 0)
                {
                    byte[] data = new byte[len];
                    bool   read = NetUtil.ReadContent(socketClient, buffer, data);
                    if (read)
                    {
                        //string strReceive = Encoding.Default.GetString(data);
                        //queueRead.Enqueue(strReceive);
                        MessageVO messageVO = new MessageVO();
                        messageVO.protocol = protocol;
                        messageVO.data     = data;
                        queueMove.Enqueue(messageVO);
                        //Debug.Log("client read from server:" + socketClient.RemoteEndPoint + "|" + strReceive);
                    }
                    else
                    {
                        OnReadContenError();
                        break;
                    }
                }
                else
                {
                    OnReadProtocolError();
                    break;
                }
            }
            else
            {
                OnReadLengthError();
                break;
            }
        }

        OnServerDisconnected();
    }
コード例 #13
0
ファイル: ThreadRootMessage.cs プロジェクト: mike442144/FBS
        public static ThreadRootMessage CreateFromReader(IDataReader r)
        {
            ThreadRootMessage msg = new ThreadRootMessage();

            msg._messageId     = new Guid(r["MessageID"].ToString());
            msg._creationDate  = Convert.ToDateTime(r["CreationDate"]);
            msg._modifiedDate  = Convert.ToDateTime(r["ModifiedDate"]);
            msg._forumThreadId = new Guid(r["ThreadID"].ToString());
            msg._forum         = new Guid(r["ForumID"].ToString());
            msg._account       = new Guid(r["AccountID"].ToString());
            MessageVO msgVO = new MessageVO();

            msgVO.Body         = HttpUtility.HtmlDecode(r["Body"].ToString());
            msgVO.RewardPoints = Convert.ToInt32(r["RewardPoints"] ?? 0);
            msgVO.Subject      = r["Subject"].ToString();

            msg._messageVO = msgVO;

            return(msg);
        }
コード例 #14
0
        public static ForumMessageReply CreateFromReader(IDataReader dr)
        {
            ForumMessageReply reply = new ForumMessageReply();

            reply._messageId     = new Guid(dr["MessageID"].ToString());
            reply._forum         = new Guid(dr["ForumID"].ToString());
            reply._account       = new Guid(dr["AccountID"].ToString());
            reply._creationDate  = Convert.ToDateTime(dr["CreationDate"]);
            reply._modifiedDate  = Convert.ToDateTime(dr["ModifiedDate"]);
            reply._forumThreadId = new Guid(dr["ThreadID"].ToString());
            MessageVO vo = new MessageVO();

            vo.Body         = Utils.Utils.HtmlDecode(dr["Body"].ToString());
            vo.Subject      = dr["Subject"].ToString();
            vo.RewardPoints = Convert.ToInt32(dr["RewardPoints"]);

            reply._messageVO = vo;

            return(reply);
        }
コード例 #15
0
        private void AcceptCallback(IAsyncResult ar)
        {
            // Signal the main thread to continue accepting new connections
            _connected.Set();

            // Accept new client socket connection
            Socket socket = _server.EndAccept(ar);

            Client client = new Client(socket);

            // Store all clients
            if (_rooms == null)
            {
                _rooms = new List <Room>()
                {
                    new Room("Default", new List <Client>())
                };
            }

            _rooms.FirstOrDefault(p => p.RoomName == "Default").AddClient(client);

            // Begin receiving messages from new connection
            try
            {
                MessageVO msg = new MessageVO();
                client.Message = msg;
                client.Socket.BeginReceive(client.Buffer, 0, MessageParameters.BufferSize, SocketFlags.None, new AsyncCallback(ReceiveCallback), client);
                SendToClient(client, "Welcome to our chat server. Please provide a nickname by Using /Name | /Help to list all commands.");
            }
            catch (SocketException)
            {
                // Client was forcebly closed on the client side
                CloseClient(client);
            }
            catch (Exception ex)
            {
                _log.Error(ex, "Error on beginning to receive messages");
                Console.WriteLine(ex.Message);
            }
        }
コード例 #16
0
        public void Test_SendMessageMail()
        {
            //建立一篇訊息
            MessageVO messageVO = new MessageVO();

            messageVO.Content     = "意見";
            messageVO.CreateName  = "張大保";
            messageVO.EMail       = "*****@*****.**";
            messageVO.Fax         = "23223333";
            messageVO.Phone       = "22234563";
            messageVO.Mobile      = "0912333444";
            messageVO.CreatedDate = DateTime.Now;
            messageVO.CreateIP    = "127.0.0.1";

            messageVO = m_MessageService.CreateMessage(messageVO);

            string classify = "聯絡我們收件者";
            IList <ItemParamVO> contactorList = m_SystemService.GetAllItemParamByNoDel(classify);

            if (contactorList != null && contactorList.Count > 0)
            {
                SystemParamVO mailVO      = m_SystemService.GetSystemParamByRoot();
                MailService   mailService = new MailService(mailVO.MailSmtp, int.Parse(mailVO.MailPort), mailVO.EnableSSL, mailVO.Account, mailVO.Password);

                StringBuilder sbMailList = new StringBuilder();
                foreach (ItemParamVO contactor in contactorList)
                {
                    sbMailList.Append(string.Format("{0};", contactor.Value));
                }

                string mailTitle   = string.Format("收到一封由【{0}】從產基會網站提出的意見信。", messageVO.CreateName);
                string mailContent = GenMailContent(messageVO);

                mailService.SendMail(mailVO.SendEmail, sbMailList.ToString(), mailTitle, mailContent);
            }
        }
コード例 #17
0
 /// <summary>
 /// 刪除訊息
 /// </summary>
 /// <param name="messageVO">被刪除的訊息</param>
 public void DeleteMessage(MessageVO messageVO)
 {
     MessageDao.DeleteMessage(messageVO);
 }
コード例 #18
0
 /// <summary>
 /// 刪除訊息
 /// </summary>
 /// <param name="messageVO">被刪除的訊息</param>
 public void DeleteMessage(MessageVO messageVO)
 {
     NHibernateDao.Delete(messageVO);
 }
コード例 #19
0
    /// <summary>
    /// 發信給設定的信箱 By 訊息
    /// </summary>
    /// <param name="messageVO"></param>
    public void SendMail_ToContactor_ByMessage(MessageVO messageVO)
    {
        try
        {
            string classify = "聯絡我們收件者";
            IList<ItemParamVO> contactorList = m_SystemService.GetAllItemParamByNoDel(classify);

            if (contactorList != null && contactorList.Count > 0)
            {
                SystemParamVO mailVO = m_SystemService.GetSystemParamByRoot();
                MailService mailService = new MailService(mailVO.MailSmtp, int.Parse(mailVO.MailPort), mailVO.EnableSSL, mailVO.Account, mailVO.Password);

                StringBuilder sbMailList = new StringBuilder();
                foreach (ItemParamVO contactor in contactorList)
                {
                    sbMailList.Append(string.Format("{0};", contactor.Value));
                }

                string mailTitle = string.Format("收到一封由【{0}】從網站發出的線上諮詢。", messageVO.CreateName);
                string mailContent = GenMailContent(messageVO);

                mailService.SendMail(mailVO.SendEmail, sbMailList.ToString(), mailTitle, mailContent);
            }
        }
        catch (Exception ex)
        {
            m_Log.Error(ex);
        }
    }
コード例 #20
0
 /// <summary>
 /// 新增訊息
 /// </summary>
 /// <param name="messageVO">被新增的訊息</param>
 /// <returns>新增後的訊息</returns>
 public MessageVO CreateMessage(MessageVO messageVO)
 {
     return(MessageDao.CreateMessage(messageVO));
 }
コード例 #21
0
 public ForumMessageReply(MessageVO messageVO, Guid account, Guid forumId, Guid parentMessageId, Guid threadId) : base(messageVO, account, forumId)
 {
     this._parentMessageId = parentMessageId;
     this._forumThreadId   = threadId;
 }
コード例 #22
0
        /// <summary>
        /// 对主题进行回复
        /// </summary>
        /// <param name="forumThread">主题实体</param>
        /// <param name="forumMessageReply">回复消息实体</param>
        public void ReplyThread(ReplyThreadModel model)
        {
            //IForumThreadRepository forumThreadRep = FBS.Factory.Factory<IForumThreadRepository>.GetConcrete();
            //IAccountRepository accountRep = FBS.Factory.Factory<IAccountRepository>.GetConcrete();
            //IForumsRepository forumsRep = FBS.Factory.Factory<IForumsRepository>.GetConcrete();
            //IForumMessageRepository msgRep = FBS.Factory.Factory<IForumMessageRepository>.GetConcrete();

            IRepository <ForumMessage> msgRep = Factory.Factory <IRepository <ForumMessage> > .GetConcrete <ForumMessage>();

            IForumThreadRepository threadRep = Factory.Factory <IForumThreadRepository> .GetConcrete();

            IRepository <Forum> forumRep = Factory.Factory <IRepository <Forum> > .GetConcrete <Forum>();

            IRepository <ForumThread> threadWriteRep = Factory.Factory <IRepository <ForumThread> > .GetConcrete <ForumThread>();

            ForumMessageReply reply   = null;
            ThreadRootMessage rootmsg = null;
            Forum             forum   = null;
            ForumThread       thread  = null;

            MessageVO mVO = new MessageVO();

            mVO.Body = model.Body;


            try
            {
                thread  = threadRep.GetByKey(model.ThreadID);
                rootmsg = thread.RootMessage;
                forum   = forumRep.GetByKey(model.ForumID);


                //主题回复数增加
                thread.AddMessageCount();
                //forum = forumsRep.GetByKey(rootmsg.Forum);
                //poster = accountRep.GetByKey(model.AccountID);


                //回复
                reply = new ForumMessageReply(mVO, model.AccountID, model.ForumID, rootmsg.Id, thread.Id);

                //加入板块的最后发表并对板块回复计数
                forum.AddNewMessage(reply);

                //更新帖子
                thread.ModifiedDate = reply.CreationDate;
                //thread.CreationDate = reply.CreationDate;
                //给主题增加回复
                msgRep.Add(reply);
                msgRep.PersistAll();

                threadWriteRep.Update(thread);
                threadWriteRep.PersistAll();

                forumRep.Update(forum);
                forumRep.PersistAll();


                //forumThreadRep.Update(thread);
                //forumThreadRep.PersistAll();
            }
            catch (Exception error) { throw new ReplyForumThreadException("回复失败,原因为:", error); }
        }
コード例 #23
0
    private string GenMailContent(MessageVO messageVO)
    {
        StringBuilder sbContent = new StringBuilder();

        sbContent.Append(string.Format("建立時間:{0}<br />", messageVO.CreatedDate.Value.ToString()));
        sbContent.Append(string.Format("預約日期:{0}<br />", messageVO.ReservationDate.Value.ToString("yyyy/MM/dd")));
        sbContent.Append(string.Format("預約時段:{0}<br />", messageVO.ReservationPeriod));
        sbContent.Append(string.Format("姓  名:{0}<br />", messageVO.CreateName));
        sbContent.Append(string.Format("連絡電話:{0}<br />", messageVO.Phone));
        sbContent.Append(string.Format("電子信箱:{0}<br />", messageVO.EMail));
        sbContent.Append(string.Format("預約內容:<br />{0}<br />", messageVO.Content.Replace("\n", "<br />")));

        return sbContent.ToString();
    }
コード例 #24
0
        private void ReceiveCallback(IAsyncResult ar)
        {
            int bytesRead;

            // Check for null values
            if (!TryGetClient(ar, out string error, out Client client))
            {
                _log.Information(error);
                return;
            }

            // Reading message from the client socket
            try
            {
                bytesRead = client.Socket.EndReceive(ar);
            }
            catch (SocketException)
            {
                _log.Information("Client closed on the client side");
                CloseClient(client);
                return;
            }
            catch (Exception ex)
            {
                _log.Error(ex, "Error on reading client socket");
                return;
            }

            if (bytesRead > 0)
            {
                client.BuildIncomingMessage(bytesRead);

                if (client.MessageReceived())
                {
                    client.Message.RemoveEndIncomingMessage();
                    var message = client.Message.IncomingMessage.FromJsonTo <Message>();

                    if (string.IsNullOrWhiteSpace(client.NickName) && string.IsNullOrWhiteSpace(message.ClientNickname))
                    {
                        SendToClient(client, "Please provide a nickname by Using /Name Command");
                        return;
                    }

                    if (!string.IsNullOrWhiteSpace(message.ClientNickname))
                    {
                        try
                        {
                            SetNickName(client, message.ClientNickname);
                            SendToClient(client, "You were registered Succesfully!");
                        }
                        catch (DuplicateNickNameException)
                        {
                            SendToClient(client, $"Sorry, the nickname {message.ClientNickname} is already taken, Please choose a differente one");
                        }
                    }
                    else if (!string.IsNullOrWhiteSpace(message.CreateRoomName))
                    {
                        RemoveClientFromRooms(client);
                        _rooms.Add(new Room(message.CreateRoomName, new List <Client>()
                        {
                            client
                        }));
                        client.SetRoomName(message.CreateRoomName);
                    }
                    else if (!string.IsNullOrWhiteSpace(message.ChangeRoomName))
                    {
                        try
                        {
                            CheckIfRoomExistsAndChange(client, message.ChangeRoomName);
                        }
                        catch (RoomDoesntExistsException)
                        {
                            SendToClient(client, "The room you tried to change doesn't exists");
                        }
                    }
                    else if (!string.IsNullOrWhiteSpace(message.ClientNameToSendMessage))
                    {
                        try
                        {
                            SendMessageToAnUser(client, message);
                        }
                        catch (ClientDoesntExistsException)
                        {
                            SendToClient(client, "The client you wanted to talk doesnt exists or isn't in the same room as you.");
                        }
                    }
                    else if (message.ListRooms)
                    {
                        string roomsName = "";
                        foreach (var room in _rooms)
                        {
                            roomsName += room.RoomName + "\n";
                        }
                        SendToClient(client, "Open rooms: \n" + roomsName);
                    }
                    else if (message.ListUsers)
                    {
                        string usersOfYourRoom = "";
                        foreach (var clientInRoom in _rooms.FirstOrDefault(p => p.RoomName == client.RoomName).Clients)
                        {
                            if (!string.IsNullOrWhiteSpace(clientInRoom.NickName))
                            {
                                usersOfYourRoom += clientInRoom.NickName + "\n";
                            }
                        }
                        SendToClient(client, "Users in you room: \n" + usersOfYourRoom);
                    }
                    else
                    {
                        Room room = _rooms.FirstOrDefault(p => p.RoomName == client.RoomName);
                        SendToAllClientRoom(room, client.NickName + " says", message.MessageToBeSend);
                    }

                    client.Message.ClearIncomingMessage();
                }
            }

            // Listen for more incoming messages
            try
            {
                MessageVO msg = new MessageVO();
                client.Message = msg;
                client.Socket.BeginReceive(client.Buffer, 0, MessageParameters.BufferSize, SocketFlags.None, new AsyncCallback(ReceiveCallback), client);
            }
            catch (SocketException)
            {
                // Client was forcebly closed on the client side
                CloseClient(client);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #25
0
ファイル: ThreadRootMessage.cs プロジェクト: mike442144/FBS
        public static ThreadRootMessage CreateFromPersist(Guid id, DateTime creationDate, DateTime modifiedDate, Guid account, Guid forumId, MessageVO msgVO)
        {
            ThreadRootMessage trm = new ThreadRootMessage();

            trm._messageId    = id;
            trm._creationDate = creationDate;
            trm._modifiedDate = modifiedDate;
            trm._account      = account;
            trm._forum        = forumId;
            trm._messageVO    = msgVO;

            return(trm);
        }
コード例 #26
0
ファイル: ThreadRootMessage.cs プロジェクト: mike442144/FBS
 public ThreadRootMessage(MessageVO messageVO, Guid account, Guid forumId) : base(messageVO, account, forumId)
 {
 }