本文整理匯總了Golang中github.com/oikomi/FishChatServer/log.Info函數的典型用法代碼示例。如果您正苦於以下問題:Golang Info函數的具體用法?Golang Info怎麽用?Golang Info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Info函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
version()
fmt.Printf("built on %s\n", BuildTime())
flag.Parse()
cfg := NewGatewayConfig(*InputConfFile)
err := cfg.LoadConfig()
if err != nil {
log.Error(err.Error())
return
}
gw := NewGateway(cfg)
gw.server, err = libnet.Listen(cfg.TransportProtocols, cfg.Listen)
if err != nil {
log.Error(err.Error())
return
}
log.Info("gateway server running at ", gw.server.Listener().Addr().String())
gw.server.Serve(func(session *libnet.Session) {
log.Info("client ", session.Conn().RemoteAddr().String(), " | come in")
go handleSession(gw, session)
})
}
示例2: procSendMessageTopic
func (self *ProtoProc) procSendMessageTopic(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procSendMessageTopic")
var err error
topicName := cmd.GetArgs()[0]
send2Msg := cmd.GetArgs()[1]
log.Info(send2Msg)
log.Info(topicName)
if self.msgServer.topics[topicName] == nil {
log.Warning(topicName + " is not exist")
} else {
resp := protocol.NewCmdSimple(protocol.RESP_MESSAGE_TOPIC_CMD)
resp.AddArg(topicName)
resp.AddArg(send2Msg)
resp.AddArg(session.State.(*base.SessionState).ClientID)
_, err = self.msgServer.topics[topicName].Channel.Broadcast(libnet.Json(resp))
if err != nil {
log.Error(err.Error())
return err
}
}
return err
}
示例3: Set
func (self *MongoStore) Set(data interface{}) error {
log.Info("MongoStore Update")
var err error
self.rwMutex.Lock()
defer self.rwMutex.Unlock()
switch data.(type) {
case *SessionStoreData:
op := self.session.DB(DATA_BASE_NAME).C(CLIENT_INFO_COLLECTION)
cid := data.(*SessionStoreData).ClientID
log.Info("cid : ", cid)
_, err = op.Upsert(bson.M{"ClientID": cid}, data.(*SessionStoreData))
if err != nil {
log.Error(err.Error())
return err
}
case *TopicStoreData:
op := self.session.DB(DATA_BASE_NAME).C(TOPIC_INFO_COLLECTION)
topicName := data.(*TopicStoreData).TopicName
log.Info("topicName : ", topicName)
_, err = op.Upsert(bson.M{"TopicName": topicName}, data.(*TopicStoreData))
if err != nil {
log.Error(err.Error())
return err
}
}
return err
}
示例4: Update
func (self *MongoStore) Update(db string, c string, data interface{}) error {
log.Info("MongoStore Update")
var err error
self.rwMutex.Lock()
defer self.rwMutex.Unlock()
op := self.session.DB(db).C(c)
switch data.(type) {
case *SessionStoreData:
cid := data.(*SessionStoreData).ClientID
log.Info("cid : ", cid)
_, err = op.Upsert(bson.M{"ClientID": cid}, data.(*SessionStoreData))
if err != nil {
log.Error(err.Error())
return err
}
case *TopicStoreData:
topicName := data.(*TopicStoreData).TopicName
log.Info("topicName : ", topicName)
_, err = op.Upsert(bson.M{"TopicName": topicName}, data.(*TopicStoreData))
if err != nil {
log.Error(err.Error())
return err
}
}
return err
}
示例5: scanDeadSession
func (self *MsgServer) scanDeadSession() {
log.Info("scanDeadSession")
timer := time.NewTicker(self.cfg.ScanDeadSessionTimeout * time.Second)
ttl := time.After(self.cfg.Expire * time.Second)
for {
select {
case <-timer.C:
log.Info("scanDeadSession timeout")
go func() {
for id, s := range self.sessions {
self.scanSessionMutex.Lock()
//defer self.scanSessionMutex.Unlock()
if (s.State).(*base.SessionState).Alive == false {
log.Info("delete" + id)
delete(self.sessions, id)
} else {
s.State.(*base.SessionState).Alive = false
}
self.scanSessionMutex.Unlock()
}
}()
case <-ttl:
break
}
}
}
示例6: procCreateTopic
func (self *ProtoProc) procCreateTopic(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procCreateTopic")
var err error
if len(cmd.GetArgs()) != 1 {
return CMD_NOT_CORRECT
}
topicName := cmd.GetArgs()[0]
topicCacheData := redis_store.NewTopicCacheData(topicName, session.State.(*base.SessionState).ClientID,
self.msgServer.cfg.LocalIP)
t := protocol.NewTopic(topicName, self.msgServer.cfg.LocalIP, session.State.(*base.SessionState).ClientID, session)
t.ClientIDList = append(t.ClientIDList, session.State.(*base.SessionState).ClientID)
t.TSD = topicCacheData
self.msgServer.topics[topicName] = t
self.msgServer.topics[topicName].Channel = libnet.NewChannel(self.msgServer.server.Protocol())
self.msgServer.topics[topicName].Channel.Join(session, nil)
log.Info(topicCacheData)
args := make([]string, 0)
args = append(args, topicName)
CCmd := protocol.NewCmdInternal(protocol.CACHE_TOPIC_CMD, args, topicCacheData)
m := redis_store.NewMember(session.State.(*base.SessionState).ClientID)
CCmd.AnyData.(*redis_store.TopicCacheData).MemberList = append(CCmd.AnyData.(*redis_store.TopicCacheData).MemberList, m)
log.Info(CCmd)
if self.msgServer.channels[protocol.SYSCTRL_TOPIC_STATUS] != nil {
_, err = self.msgServer.channels[protocol.SYSCTRL_TOPIC_STATUS].Channel.Broadcast(libnet.Json(CCmd))
if err != nil {
log.Error(err.Error())
return err
}
}
// store topic
topicStoreData := mongo_store.NewTopicStoreData(topicName, session.State.(*base.SessionState).ClientID,
self.msgServer.cfg.LocalIP)
args = make([]string, 0)
args = append(args, topicName)
CCmd = protocol.NewCmdInternal(protocol.STORE_TOPIC_CMD, args, topicStoreData)
member := mongo_store.NewMember(session.State.(*base.SessionState).ClientID)
CCmd.AnyData.(*mongo_store.TopicStoreData).MemberList = append(CCmd.AnyData.(*mongo_store.TopicStoreData).MemberList, member)
log.Info(CCmd)
if self.msgServer.channels[protocol.STORE_TOPIC_INFO] != nil {
_, err = self.msgServer.channels[protocol.STORE_TOPIC_INFO].Channel.Broadcast(libnet.Json(CCmd))
if err != nil {
log.Error(err.Error())
return err
}
}
return nil
}
示例7: 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 := ""
if len(cmd.GetArgs()) == 3 {
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)
self.gateway.sessionCache.Set(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
}
示例8: procStoreSession
func (self *ProtoProc) procStoreSession(data interface{}, session *libnet.Session) error {
log.Info("procStoreSession")
var err error
log.Info(data)
err = self.Manager.mongoStore.Update(mongo_store.DATA_BASE_NAME, mongo_store.CLIENT_INFO_COLLECTION, data)
if err != nil {
return err
log.Error("error:", err)
}
return nil
}
示例9: procStoreSession
func (self *ProtoProc) procStoreSession(data interface{}, session *libnet.Session) error {
log.Info("procStoreSession")
var err error
log.Info(data)
err = self.Manager.mongoStore.Set(data.(*mongo_store.SessionStoreData))
if err != nil {
return err
log.Error("error:", err)
}
return nil
}
示例10: procClientID
func (self *ProtoProc) procClientID(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procClientID")
var err error
ID := cmd.GetArgs()[0]
// for cache data
sessionCacheData := redis_store.NewSessionCacheData(cmd.GetArgs()[0], session.Conn().RemoteAddr().String(),
self.msgServer.cfg.LocalIP, strconv.FormatUint(session.Id(), 10))
log.Info(sessionCacheData)
args := make([]string, 0)
args = append(args, cmd.GetArgs()[0])
CCmd := protocol.NewCmdInternal(protocol.CACHE_SESSION_CMD, args, sessionCacheData)
log.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 {
log.Error(err.Error())
return err
}
}
// for store data
sessionStoreData := mongo_store.SessionStoreData{ID, session.Conn().RemoteAddr().String(),
self.msgServer.cfg.LocalIP, true}
log.Info(sessionStoreData)
args = make([]string, 0)
args = append(args, cmd.GetArgs()[0])
CCmd = protocol.NewCmdInternal(protocol.STORE_SESSION_CMD, args, sessionStoreData)
log.Info(CCmd)
if self.msgServer.channels[protocol.STORE_CLIENT_INFO] != nil {
_, err = self.msgServer.channels[protocol.STORE_CLIENT_INFO].Channel.Broadcast(libnet.Json(CCmd))
if err != nil {
log.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 {
log.Error(err.Error())
return err
}
return nil
}
示例11: procCacheTopic
func (self *ProtoProc) procCacheTopic(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procCacheTopic")
var err error
log.Info(cmd.GetAnyData())
err = self.Manager.topicCache.Set(cmd.GetAnyData().(*redis_store.TopicCacheData))
if err != nil {
return err
log.Error("error:", err)
}
log.Info("set sesion id success")
return nil
}
示例12: procSubscribeChannel
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)
}
示例13: subscribeChannels
func (self *Monitor) subscribeChannels() error {
log.Info("monitor start to subscribeChannels")
for _, ms := range self.cfg.MsgServerList {
msgServerClient, err := self.connectMsgServer(ms)
if err != nil {
log.Error(err.Error())
return err
}
cmd := protocol.NewCmdSimple(protocol.SUBSCRIBE_CHANNEL_CMD)
cmd.AddArg(protocol.SYSCTRL_MONITOR)
cmd.AddArg(self.cfg.UUID)
err = msgServerClient.Send(libnet.Json(cmd))
if err != nil {
log.Error(err.Error())
return err
}
self.msgServerClientMap[ms] = msgServerClient
}
for _, msc := range self.msgServerClientMap {
go self.handleMsgServerClient(msc)
}
return nil
}
示例14: createChannels
func (self *MsgServer) createChannels() {
log.Info("createChannels")
for _, c := range base.ChannleList {
channel := libnet.NewChannel(self.server.Protocol())
self.channels[c] = base.NewChannelState(c, channel)
}
}
示例15: sendMonitorData
func (self *MsgServer) sendMonitorData() error {
log.Info("sendMonitorData")
resp := protocol.NewCmdMonitor()
// resp.SessionNum = (uint64)(len(self.sessions))
// log.Info(resp)
mb := NewMonitorBeat("monitor", self.cfg.MonitorBeatTime, 40, 10)
if self.channels[protocol.SYSCTRL_MONITOR] != nil {
for {
resp.SessionNum = (uint64)(len(self.sessions))
//log.Info(resp)
mb.Beat(self.channels[protocol.SYSCTRL_MONITOR].Channel, resp)
}
// _, err := self.channels[protocol.SYSCTRL_MONITOR].Channel.Broadcast(libnet.Json(resp))
// if err != nil {
// glog.Error(err.Error())
// return err
// }
}
return nil
}