app.go (675B)
1 package main 2 3 import ( 4 "golang.org/x/net/websocket" 5 "sync" 6 ) 7 8 type TApp struct { 9 Connection *websocket.Conn 10 WaitGroup sync.WaitGroup 11 Config TConfig 12 User *TUser 13 Auth *TAuth 14 } 15 16 func (app *TApp) InitConfig() error { 17 if app.Config.IsInited() { 18 return nil 19 } else { 20 return app.Config.Init() 21 } 22 } 23 24 func (app *TApp) InitAuth(auth_code string) error { 25 if app.Auth == nil { 26 app.Auth = new(TAuth) 27 } 28 if app.Auth.IsInited() { 29 return nil 30 } else { 31 return app.Auth.Init(auth_code) 32 } 33 } 34 35 func (app *TApp) InitUser() error { 36 if app.User == nil { 37 app.User = new(TUser) 38 } 39 if app.User.IsInited() { 40 return nil 41 } else { 42 return app.User.Init() 43 } 44 }