func NewSignUp(name string) *SignUp { network := config.Config().SetSection("server").ValueOf("protocol") ip := config.Config().SetSection("server").ValueOf("ip") port := config.Config().SetSection("server").ValueOf("port") address := ip + ":" + port return &SignUp{name, 0, "", nil, network, address, int(time.Now().Unix())} }
func NewSignIn(account int, password string) *SignIn { network := config.Config().SetSection("server").ValueOf("protocol") ip := config.Config().SetSection("server").ValueOf("ip") port := config.Config().SetSection("server").ValueOf("port") address := ip + ":" + port user := data.User{ID: account, Nickname: "", AvatarUrl: "", Password: password, Friends: make([]string, 0)} return &SignIn{user, nil, network, address, int(time.Now().Unix()), false} }
func main() { log.Println("初始化服务器... (按下Ctrl-C停止服务)") protocol := config.Config().SetSection("server").ValueOf("protocol") ip := config.Config().SetSection("server").ValueOf("ip") port := config.Config().SetSection("server").ValueOf("port") addr := ip + ":" + port log.Println("监听地址: " + addr) log.Println("协议: " + protocol) s := server.NewServer(protocol, addr) defer s.Close() s.Listen() s.Run() }
func NewDBManager() (*DBManager, error) { ip := config.Config().SetSection("db").ValueOf("ip") session, err := mgo.Dial(ip) if err != nil { return nil, err } return &DBManager{session}, nil }