Example #1
0
func (self *ProtoProc) procClientID(cmd protocol.Cmd, session *libnet.Session) error {
	glog.Info("procClientID")
	var err error
	ID := cmd.GetArgs()[0]
	sessionStoreData := storage.NewSessionStoreData(cmd.GetArgs()[0], session.Conn().RemoteAddr().String(),
		self.msgServer.cfg.LocalIP, strconv.FormatUint(session.Id(), 10))

	glog.Info(sessionStoreData)
	args := make([]string, 0)
	args = append(args, cmd.GetArgs()[0])
	CCmd := protocol.NewCmdInternal(protocol.STORE_SESSION_CMD, args, sessionStoreData)

	glog.Info(CCmd)

	if self.msgServer.channels[protocol.SYSCTRL_CLIENT_STATUS] != nil {
		_, err = self.msgServer.channels[protocol.SYSCTRL_CLIENT_STATUS].Channel.Broadcast(libnet.Json(CCmd))
		if err != nil {
			glog.Error(err.Error())
			return err
		}
	}

	self.msgServer.sessions[cmd.GetArgs()[0]] = session
	self.msgServer.sessions[cmd.GetArgs()[0]].State = base.NewSessionState(true, cmd.GetArgs()[0])

	err = self.procOfflineMsg(session, ID)
	if err != nil {
		glog.Error(err.Error())
		return err
	}
	return nil
}