本文整理汇总了Golang中FishChatServer/log.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: 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
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:30,代码来源:mongo_store.go
示例2: 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)
self.procOffline(id)
} else {
s.State.(*base.SessionState).Alive = false
}
self.scanSessionMutex.Unlock()
}
}()
case <-ttl:
break
}
}
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:26,代码来源:server.go
示例3: 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
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:54,代码来源:proto_proc.go
示例4: 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
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:12,代码来源:proto_proc.go
示例5: 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
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:13,代码来源:proto_proc.go
示例6: 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)
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:14,代码来源:proto_proc.go
示例7: GetOfflineMsgFromOwnerName
func GetOfflineMsgFromOwnerName(storeOp interface{}, ownerName string) (*redis_store.OfflineMsgCacheData, error) {
switch storeOp.(type) {
case *redis_store.OfflineMsgCache:
o, err := storeOp.(*redis_store.OfflineMsgCache).Get(ownerName)
if err != nil {
log.Warningf("no ownerName : %s", ownerName)
return nil, err
}
if o != nil {
log.Info(o)
}
return o, nil
}
return nil, NOTFOUNT
// o ,err := offlineMsgCache.Get(ownerName)
// if err != nil {
// log.Warningf("no ownerName : %s", ownerName)
// return nil, err
// }
// if o != nil {
// log.Info(o)
// }
// return o, nil
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:30,代码来源:util.go
示例8: main
func main() {
version()
fmt.Printf("built on %s\n", BuildTime())
flag.Parse()
cfg := NewRouterConfig(*InputConfFile)
err := cfg.LoadConfig()
if err != nil {
log.Error(err.Error())
return
}
server, err := libnet.Listen(cfg.TransportProtocols, cfg.Listen)
if err != nil {
log.Error(err.Error())
return
}
log.Info("server start: ", server.Listener().Addr().String())
rs := redis_store.NewRedisStore(&redis_store.RedisStoreOptions{
Network: "tcp",
Address: cfg.Redis.Addr + cfg.Redis.Port,
ConnectTimeout: time.Duration(cfg.Redis.ConnectTimeout) * time.Millisecond,
ReadTimeout: time.Duration(cfg.Redis.ReadTimeout) * time.Millisecond,
WriteTimeout: time.Duration(cfg.Redis.WriteTimeout) * time.Millisecond,
Database: 1,
KeyPrefix: base.COMM_PREFIX,
})
r := NewRouter(cfg, rs)
//TODO not use go
go r.subscribeChannels()
server.Serve(func(session *libnet.Session) {
})
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:34,代码来源:router.go
示例9: procQuitTopic
/*
client -> MsgServer
REQ_QUIT_TOPIC_CMD
arg0: TopicName //群组名
MsgServer -> client
RSP_QUIT_TOPIC_CMD
arg0: SUCCESS/ERROR
*/
func (self *ProtoProc) procQuitTopic(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procQuitTopic")
var err error
if len(cmd.GetArgs()) != 1 {
err = common.SYNTAX_ERROR
} else {
topicName := cmd.GetArgs()[0]
clientID := session.State.(*base.SessionState).ClientID
err = self.msgServer.procQuitTopic(clientID, topicName)
}
resp := protocol.NewCmdSimple(protocol.RSP_QUIT_TOPIC_CMD)
if err != nil {
resp.AddArg(err.Error())
} else {
resp.AddArg(protocol.RSP_SUCCESS)
}
err = session.Send(libnet.Json(resp))
if err != nil {
log.Error(err.Error())
}
return err
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:37,代码来源:proto_proc.go
示例10: procRouteMessageP2P
/*
Router -> MsgServer
ROUTE_SEND_P2P_MSG_CMD
arg0: Sent2ID //接收方用户ID
arg1: Msg //消息内容
arg2: FromID //发送方用户ID
arg3: uuid //MsgServer分配的消息uuid
发送给消息接受者的消息
MsgServer -> device/client
REQ_SEND_P2P_MSG_CMD
arg0: Msg //消息内容
arg1: FromID //发送方用户ID
arg2: uuid //MsgServer分配的消息uuid,可选,如果提供了则须IND_ACK_P2P_STATUS_CMD(ClientID, uuid)
*/
func (self *ProtoProc) procRouteMessageP2P(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procRouteMessageP2P")
var err error
send2ID := cmd.GetArgs()[0]
send2Msg := cmd.GetArgs()[1]
fromID := cmd.GetArgs()[2]
uuid := cmd.GetArgs()[3]
if self.msgServer.sessions[send2ID] != nil {
resp := protocol.NewCmdSimple(protocol.REQ_SEND_P2P_MSG_CMD)
resp.AddArg(send2Msg)
resp.AddArg(fromID)
// add uuid
resp.AddArg(uuid)
err = self.msgServer.sessions[send2ID].Send(libnet.Json(resp))
if err != nil {
log.Fatalln(err.Error())
} else {
self.procP2PAckStatus(fromID, uuid, protocol.P2P_ACK_SENT)
}
}
return nil
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:41,代码来源:proto_proc.go
示例11: procRouteTopicMsg
/*
通过Router转发消息(对终端开发者不可见)
Router -> MsgServer
ROUTE_SEND_TOPIC_MSG_CMD
arg0: Msg //消息内容
arg1: TopicName //群组名
arg2: ClientID //发送方用户ID
arg3: ClientType //发送方终端类型,是client还是device
*/
func (self *ProtoProc) procRouteTopicMsg(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procRouteTopicMsg")
var err error
//send2Msg := cmd.GetArgs()[0]
topicName := cmd.GetArgs()[1]
//fromID := cmd.GetArgs()[2]
//fromType := cmd.GetArgs()[3]
// check whether the topic exist
topicCacheData, err := self.msgServer.topicCache.Get(topicName)
if topicCacheData == nil {
log.Warningf("TOPIC %s not exist: %s", topicName, err.Error())
return common.TOPIC_NOT_EXIST
}
cmd.ChangeCmdName(protocol.REQ_SEND_TOPIC_MSG_CMD)
// exactly in this server, just broadcasting
log.Warningf("topic %s has %d member(s) in this server", topicName, topicCacheData.AliveMemberNumMap[self.msgServer.cfg.LocalIP])
for _, mID := range topicCacheData.MemberList {
if self.msgServer.sessions[mID.ID] != nil {
self.msgServer.sessions[mID.ID].Send(libnet.Json(cmd))
if err != nil {
log.Fatalln(err.Error())
}
}
}
return nil
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:40,代码来源:proto_proc.go
示例12: 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
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:26,代码来源:server.go
示例13: handleMsgServerClient
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
})
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:33,代码来源:server.go
示例14: main
func main() {
version()
fmt.Printf("built on %s\n", BuildTime())
flag.Parse()
cfg := NewMonitorConfig(*InputConfFile)
err := cfg.LoadConfig()
if err != nil {
log.Error(err.Error())
return
}
server, err := libnet.Listen(cfg.TransportProtocols, cfg.Listen)
if err != nil {
log.Error(err.Error())
return
}
log.Info("server start: ", server.Listener().Addr().String())
m := NewMonitor(cfg)
//TODO not use go
m.subscribeChannels()
go server.Serve(func(session *libnet.Session) {
})
beego.Router("api/v1/monitor", &controllers.MonitorController{})
//beego.SetStaticPath("/views", "/mh/mygo/src/FishChatServer/monitor/views")
beego.SetStaticPath("/views", "views")
beego.Run()
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:30,代码来源:monitor.go
示例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
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:26,代码来源:server.go
示例16: 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)
}
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:7,代码来源:server.go
示例17: procJoinTopic
/*
client -> MsgServer
REQ_JOIN_TOPIC_CMD
arg0: TopicName //群组名
arg1: ClientName //用户在Topic中的Name, 比如老爸/老妈
MsgServer -> client
RSP_JOIN_TOPIC_CMD
arg0: SUCCESS/FAILED
*/
func (self *ProtoProc) procJoinTopic(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procJoinTopic")
var err error
if len(cmd.GetArgs()) != 2 {
err = common.SYNTAX_ERROR
} else {
topicName := cmd.GetArgs()[0]
clientName := cmd.GetArgs()[1]
clientID := session.State.(*base.SessionState).ClientID
clientType := session.State.(*base.SessionState).ClientType
member := mongo_store.NewMember(clientID, clientName, clientType)
err = self.msgServer.procJoinTopic(member, topicName)
}
resp := protocol.NewCmdSimple(protocol.RSP_JOIN_TOPIC_CMD)
if err != nil {
resp.AddArg(err.Error())
} else {
resp.AddArg(protocol.RSP_SUCCESS)
}
err = session.Send(libnet.Json(resp))
if err != nil {
log.Error(err.Error())
}
return err
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:41,代码来源:proto_proc.go
示例18: procGetTopicList
func (self *ProtoProc) procGetTopicList(cmd protocol.Cmd, session *libnet.Session) error {
log.Info("procGetTopicList")
var err error
resp := protocol.NewCmdSimple(protocol.RSP_GET_TOPIC_LIST_CMD)
clientID := session.State.(*base.SessionState).ClientID
//clientType := session.State.(*base.SessionState).ClientType
sessionCacheData, err := self.msgServer.sessionCache.Get(clientID)
if sessionCacheData == nil {
log.Warningf("Client %s not online", clientID)
err = common.NOT_ONLINE
goto ErrOut
}
ErrOut:
if err != nil {
resp.AddArg(err.Error())
} else {
resp.AddArg(protocol.RSP_SUCCESS)
resp.AddArg(strconv.Itoa(len(sessionCacheData.TopicList)))
for _, topic := range sessionCacheData.TopicList {
resp.AddArg(topic)
}
}
err = session.Send(libnet.Json(resp))
if err != nil {
log.Error(err.Error())
}
return err
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:32,代码来源:proto_proc.go
示例19: GetSessionFromCID
func GetSessionFromCID(storeOp interface{}, ID string) (interface{}, error) {
switch storeOp.(type) {
case *redis_store.SessionCache:
// return (*redis_store.SessionCacheData)
SessionCacheData, err := storeOp.(*redis_store.SessionCache).Get(ID)
if err != nil {
log.Warningf("no ID : %s", ID)
return nil, err
}
if SessionCacheData != nil {
log.Info(SessionCacheData)
}
return SessionCacheData, nil
case *mongo_store.MongoStore:
// return (*mongo_store.sessionStoreData)
sessionStoreData, err := storeOp.(*mongo_store.MongoStore).GetSessionFromCid(ID)
if err != nil {
log.Warningf("no ID : %s", ID)
return nil, err
}
if sessionStoreData != nil {
log.Info(sessionStoreData)
}
return sessionStoreData, nil
}
return nil, NOTFOUNT
// session ,err := sessionCache.Get(ID)
// if err != nil {
// log.Warningf("no ID : %s", ID)
// return nil, err
// }
// if session != nil {
// log.Info(session)
// }
// return session, nil
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:45,代码来源:util.go
示例20: GetTopicFromTopicName
func GetTopicFromTopicName(storeOp interface{}, topicName string) (interface{}, error) {
switch storeOp.(type) {
case *redis_store.TopicCache:
// return (*redis_store.TopicCacheData)
TopicCacheData, err := storeOp.(*redis_store.TopicCache).Get(topicName)
if err != nil {
log.Warningf("no topicName : %s", topicName)
return nil, err
}
if TopicCacheData != nil {
log.Info(TopicCacheData)
}
return TopicCacheData, nil
case *mongo_store.MongoStore:
// return (*mongo_store.TopicStoreData)
TopicStoreData, err := storeOp.(*mongo_store.MongoStore).GetTopicFromCid(topicName)
if err != nil {
log.Warningf("no topicName : %s", topicName)
return nil, err
}
if TopicStoreData != nil {
log.Info(TopicStoreData)
}
return TopicStoreData, nil
}
return nil, NOTFOUNT
// topic ,err := topicCache.Get(topicName)
// if err != nil {
// log.Warningf("no topicName : %s", topicName)
// return nil, err
// }
// if topic != nil {
// log.Info(topic)
// }
// return topic, nil
}
开发者ID:miffa,项目名称:FishChatServer,代码行数:44,代码来源:util.go
注:本文中的FishChatServer/log.Info函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论