Exemple #1
0
func (self *Manager) handleMsgServerClient(msc *link.Session) {
	msc.ReadLoop(func(msg link.InBuffer) {
		glog.Info("msg_server", msc.Conn().RemoteAddr().String(), "say:", string(msg.Get()))

		self.parseProtocol(msg.Get(), msc)
	})
}
Exemple #2
0
func (self *Router) handleMsgServerClient(msc *link.Session) {
	msc.ReadLoop(func(msg link.InBuffer) {
		glog.Info("msg_server", msc.Conn().RemoteAddr().String(), " say: ", string(msg.Get()))
		var c protocol.CmdInternal
		pp := NewProtoProc(self)
		err := json.Unmarshal(msg.Get(), &c)
		if err != nil {
			glog.Error("error:", err)
		}
		switch c.GetCmdName() {
		case protocol.SEND_MESSAGE_P2P_CMD:
			err := pp.procSendMsgP2P(c, msc)
			if err != nil {
				glog.Warning(err.Error())
			}
		case protocol.CREATE_TOPIC_CMD:
			err := pp.procCreateTopic(c, msc)
			if err != nil {
				glog.Warning(err.Error())
			}
		case protocol.JOIN_TOPIC_CMD:
			err := pp.procJoinTopic(c, msc)
			if err != nil {
				glog.Warning(err.Error())
			}
		case protocol.SEND_MESSAGE_TOPIC_CMD:
			err := pp.procSendMsgTopic(c, msc)
			if err != nil {
				glog.Warning(err.Error())
			}

		}
	})
}
Exemple #3
0
func handleSession(ms *MsgServer, session *link.Session) {
	session.ReadLoop(func(msg link.InBuffer) {
		glog.Info(string(msg.Get()))

		err := ms.parseProtocol(msg.Get(), session)
		if err != nil {
			glog.Error(err.Error())
		}
	})
}