예제 #1
0
파일: server.go 프로젝트: sshitaime/gopush
func NewMsgServer(cfg *MsgServerConfig) *MsgServer {
	return &MsgServer{
		cfg:      cfg,
		sessions: make(base.SessionMap),
		channels: make(base.ChannelMap),
		topics:   make(protocol.TopicMap),
		server:   new(link.Server),
		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:      "push",
		})),
		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:      "push",
		})),
	}
}
예제 #2
0
파일: server.go 프로젝트: sshitaime/gopush
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:      "push",
		})),
		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:      "push",
		})),
	}
}
예제 #3
0
파일: server.go 프로젝트: sshitaime/gopush
func NewRouter(cfg *RouterConfig) *Router {
	return &Router{
		cfg:                cfg,
		msgServerClientMap: make(map[string]*link.Session),
		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:      "push",
		})),
		topicServerMap: make(map[string]string),
	}
}