コード例 #1
0
ファイル: server.go プロジェクト: iguchunhui/FishChatServer
func NewMsgServer(cfg *MsgServerConfig, rs *storage.RedisStore) *MsgServer {
	return &MsgServer{
		cfg:             cfg,
		sessions:        make(base.SessionMap),
		channels:        make(base.ChannelMap),
		topics:          make(protocol.TopicMap),
		server:          new(libnet.Server),
		sessionStore:    storage.NewSessionStore(rs),
		topicStore:      storage.NewTopicStore(rs),
		offlineMsgStore: storage.NewOfflineMsgStore(rs),
	}
}
コード例 #2
0
ファイル: server.go プロジェクト: iguchunhui/FishChatServer
func NewRouter(cfg *RouterConfig) *Router {
	return &Router{
		cfg:                cfg,
		msgServerClientMap: make(map[string]*libnet.Session),
		sessionStore: storage.NewSessionStore(storage.NewRedisStore(&storage.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,
		})),
		topicServerMap: make(map[string]string),
	}
}
コード例 #3
0
ファイル: server.go プロジェクト: iguchunhui/FishChatServer
func NewManager(cfg *ManagerConfig) *Manager {
	return &Manager{
		cfg: cfg,
		sessionStore: storage.NewSessionStore(storage.NewRedisStore(&storage.RedisStoreOptions{
			Network:        "tcp",
			Address:        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,
		})),
		topicStore: storage.NewTopicStore(storage.NewRedisStore(&storage.RedisStoreOptions{
			Network:        "tcp",
			Address:        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,
		})),
	}
}