本文整理匯總了Golang中FishChatServer/libnet.Session.Close方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.Close方法的具體用法?Golang Session.Close怎麽用?Golang Session.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類FishChatServer/libnet.Session
的用法示例。
在下文中一共展示了Session.Close方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: procLogin
func (self *ProtoProc) procLogin(cmd protocol.Cmd, session *libnet.Session) error {
//log.Info("procLogin")
var err error
var uuid string
var msgServer string
ClientID := cmd.GetArgs()[0]
ClientType := cmd.GetArgs()[1]
ClientPwd := cmd.GetArgs()[2]
// get the session cache
sessionCacheData, err := self.gateway.sessionCache.Get(ClientID)
if sessionCacheData != nil {
log.Warningf("ID %s already login", ClientID)
msgServer = sessionCacheData.MsgServerAddr
uuid = sessionCacheData.ID
} else {
// choose msg server and allocate UUID
msgServer = self.procGetMinLoadMsgServer()
uuid = common.NewV4().String()
// get the session store to check whether registered
sessionStoreData, _ := self.gateway.mongoStore.GetSessionFromCid(ClientID)
if sessionStoreData == nil {
log.Warningf("ID %s not registered", ClientID)
// for store data
sessionStoreData = mongo_store.NewSessionStoreData(ClientID, ClientPwd, ClientType)
log.Info(sessionStoreData)
common.StoreData(self.gateway.mongoStore, sessionStoreData)
}
// for cache data, MsgServer MUST update local & remote addr.
sessionCacheData = redis_store.NewSessionCacheData(sessionStoreData, session.Conn().RemoteAddr().String(), msgServer, uuid)
log.Info(sessionCacheData)
common.StoreData(self.gateway.sessionCache, sessionCacheData)
}
//
resp := protocol.NewCmdSimple(protocol.RSP_LOGIN_CMD)
resp.AddArg(protocol.RSP_SUCCESS)
resp.AddArg(uuid)
resp.AddArg(msgServer)
log.Info("Resp | ", resp)
if session != nil {
err = session.Send(libnet.Json(resp))
if err != nil {
log.Error(err.Error())
}
session.Close()
log.Info("client ", session.Conn().RemoteAddr().String(), " | close")
}
return nil
}