示例#1
0
func (self *ProtoProc) procCreateTopic(cmd protocol.Cmd, session *link.Session) error {
	glog.Info("procCreateTopic")
	topicName := cmd.GetArgs()[0]
	serverAddr := cmd.GetAnyData().(string)
	self.Router.topicServerMap[topicName] = serverAddr

	return nil
}
示例#2
0
func (self *ProtoProc) procStoreTopic(cmd protocol.Cmd, session *link.Session) error {
	glog.Info("procStoreTopic")
	var err error
	glog.Info(cmd.GetAnyData())
	err = self.Manager.topicStore.Set(cmd.GetAnyData().(*storage.TopicStoreData))
	if err != nil {
		glog.Error("error:", err)
	}
	glog.Info("set sesion id success")

	return nil
}
示例#3
0
func (self *ProtoProc) procSendMsgP2P(cmd protocol.Cmd, session *link.Session) error {
	glog.Info("procSendMsgP2P")
	var err error
	send2ID := cmd.GetArgs()[0]
	send2Msg := cmd.GetArgs()[1]
	glog.Info(send2Msg)
	self.Router.readMutex.Lock()
	defer self.Router.readMutex.Unlock()
	store_session, err := common.GetSessionFromCID(self.Router.sessionStore, send2ID)
	if err != nil {
		glog.Warningf("no ID : %s", send2ID)

		return err
	}
	glog.Info(store_session.MsgServerAddr)

	cmd.ChangeCmdName(protocol.ROUTE_MESSAGE_P2P_CMD)

	err = self.Router.msgServerClientMap[store_session.MsgServerAddr].Send(link.JSON{
		cmd,
	})
	if err != nil {
		glog.Error("error:", err)
		return err
	}

	return nil
}