Change how server address is specified
now you spell it as such: gobot -addr wss://hackerbots.us gobot -addr ws://localhost:8666
This commit is contained in:
parent
35cb8431f6
commit
c21e0c5582
@ -11,9 +11,9 @@ import (
|
|||||||
"hackerbots.us/server"
|
"hackerbots.us/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func connect(server string, port int) (*websocket.Conn, error) {
|
func connect(addr string) (*websocket.Conn, error) {
|
||||||
origin := "http://localhost/"
|
origin := "http://localhost/"
|
||||||
url := fmt.Sprintf("ws://%s:%d/ws/", server, port)
|
url := fmt.Sprintf("%s/ws/", addr)
|
||||||
return websocket.Dial(url, "", origin)
|
return websocket.Dial(url, "", origin)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,6 @@ type Client struct {
|
|||||||
ForceJSON bool
|
ForceJSON bool
|
||||||
GameId string
|
GameId string
|
||||||
Name string
|
Name string
|
||||||
Port int
|
|
||||||
Server string
|
Server string
|
||||||
StatsReq server.StatsRequest
|
StatsReq server.StatsRequest
|
||||||
Game server.GameParam
|
Game server.GameParam
|
||||||
@ -53,7 +52,7 @@ type decoder interface {
|
|||||||
|
|
||||||
// Negotiate runs through the hackerbots negociation protocol.
|
// Negotiate runs through the hackerbots negociation protocol.
|
||||||
func (c *Client) Negotiate(clientType string, player Player) (err error) {
|
func (c *Client) Negotiate(clientType string, player Player) (err error) {
|
||||||
c.ws, err = connect(c.Server, c.Port)
|
c.ws, err = connect(c.Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.New(fmt.Sprintf("connection failure: %s", err))
|
return errors.New(fmt.Sprintf("connection failure: %s", err))
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ import (
|
|||||||
"hackerbots.us/server"
|
"hackerbots.us/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
var serverHostname = flag.String("server", "localhost", "server hostname")
|
var addr = flag.String("addr", "ws://localhost:8666", "server hostname")
|
||||||
var port = flag.Int("port", 8666, "server port")
|
|
||||||
var forceJSON = flag.Bool("json", false, "force json encoding")
|
var forceJSON = flag.Bool("json", false, "force json encoding")
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -26,8 +25,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c := &client.Client{
|
c := &client.Client{
|
||||||
Server: *serverHostname,
|
Server: *addr,
|
||||||
Port: *port,
|
|
||||||
Name: "bspect",
|
Name: "bspect",
|
||||||
GameId: gameId,
|
GameId: gameId,
|
||||||
ForceJSON: *forceJSON,
|
ForceJSON: *forceJSON,
|
||||||
|
@ -23,8 +23,7 @@ var weaponSpeed = flag.Int("wspeed", 50, "weapons speed")
|
|||||||
|
|
||||||
// XXX: add TurnSpeed, WeaponDamage, WeaponSpeed
|
// XXX: add TurnSpeed, WeaponDamage, WeaponSpeed
|
||||||
|
|
||||||
var serverHostname = flag.String("server", "localhost", "server hostname")
|
var addr = flag.String("addr", "ws://localhost:8666", "server hostname")
|
||||||
var port = flag.Int("port", 8666, "server port")
|
|
||||||
var botname = flag.String("name", "gobot", "the name that other players will see")
|
var botname = flag.String("name", "gobot", "the name that other players will see")
|
||||||
var forceJSON = flag.Bool("json", false, "force json encoding")
|
var forceJSON = flag.Bool("json", false, "force json encoding")
|
||||||
var botType = flag.String("bot", "simple", "which Bot")
|
var botType = flag.String("bot", "simple", "which Bot")
|
||||||
@ -40,8 +39,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c := &client.Client{
|
c := &client.Client{
|
||||||
Server: *serverHostname,
|
Server: *addr,
|
||||||
Port: *port,
|
|
||||||
Name: *botname,
|
Name: *botname,
|
||||||
GameId: gameId,
|
GameId: gameId,
|
||||||
// XXX: update with missing fields
|
// XXX: update with missing fields
|
||||||
|
Loading…
Reference in New Issue
Block a user