Exemplo n.º 1
0
func (self *Router) handleMsgServerClient(msc *libnet.Session) {
	msc.Process(func(msg *libnet.InBuffer) error {
		log.Info("msg_server", msc.Conn().RemoteAddr().String(), " say: ", string(msg.Data))
		var c protocol.CmdInternal
		pp := NewProtoProc(self)
		err := json.Unmarshal(msg.Data, &c)
		if err != nil {
			log.Error("error:", err)
			return err
		}
		switch c.GetCmdName() {
		case protocol.REQ_SEND_P2P_MSG_CMD:
			err := pp.procSendMsgP2P(&c, msc)
			if err != nil {
				log.Warning(err.Error())
			}

		case protocol.IND_ACK_P2P_STATUS_CMD:
			err := pp.procAckP2pStatus(&c, msc)
			if err != nil {
				log.Warning(err.Error())
			}

		case protocol.REQ_SEND_TOPIC_MSG_CMD:
			err := pp.procSendMsgTopic(&c, msc)
			if err != nil {
				log.Warning(err.Error())
			}

		}
		return nil
	})
}
Exemplo n.º 2
0
func (self *ProtoProc) procSubscribeChannel(cmd protocol.Cmd, session *libnet.Session) {
	log.Info("procSubscribeChannel")
	channelName := cmd.GetArgs()[0]
	cUUID := cmd.GetArgs()[1]
	log.Info(channelName)
	if self.msgServer.channels[channelName] != nil {
		self.msgServer.channels[channelName].Channel.Join(session, nil)
		self.msgServer.channels[channelName].ClientIDlist = append(self.msgServer.channels[channelName].ClientIDlist, cUUID)
	} else {
		log.Warning(channelName + " is not exist")
	}

	log.Info(self.msgServer.channels)
}