gamerpc

package
v0.0.0-...-0e76970 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Copyright 2016 The Web BSD Hunt Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

//////////////////////////////////////////////////////////////////////////////

TODO: High-level file comment.

Index

Constants

View Source
const (
	ServerVersion = 0xFFFFFFFF

	C_PLAYER  = 0 // response: game play tcp port
	C_MONITOR = 1 // response: like C_PLAYER, but no response if 0 players
	C_MESSAGE = 2 // response: number of players currently in the game
	C_SCORES  = 3 // response: statistics tcp port

	Q_CLOAK = 1 // enter: cloaked
	Q_FLY   = 2 // enter: flying
	Q_SCAN  = 3 // enter: scanning
)
View Source
const (
	GR_NETRPC = iota + 1
	GR_JSONRPC
)

Variables

This section is empty.

Functions

func ContentTypeIsJSON

func ContentTypeIsJSON(header http.Header) error

TODO(tadhunt): find a better home for this

func StringToRpcType

func StringToRpcType(str string) (int, error)

Types

type ConnectEvent

type ConnectEvent struct {
	Token int
	Err   error
}

type GameClient

type GameClient struct {
	URL           *url.URL
	RpcType       int
	RProxyOptions uint64
}

func NewGameClient

func NewGameClient(ustr string, rpcTypeStr string, rpOptions uint64) (*GameClient, error)

func (*GameClient) GameData

func (gc *GameClient) GameData(r *http.Request, req *GameDataRequest) (*GameDataReply, error)

func (*GameClient) Input

func (gc *GameClient) Input(r *http.Request, req *InputRequest) (*InputReply, error)

func (*GameClient) Join

func (gc *GameClient) Join(r *http.Request, req *JoinRequest) (*JoinReply, error)

func (*GameClient) Message

func (gc *GameClient) Message(r *http.Request, req *MessageRequest) (*MessageReply, error)

func (*GameClient) Ping

func (gc *GameClient) Ping(r *http.Request, req *PingRequest) (*PingReply, error)

func (*GameClient) Quit

func (gc *GameClient) Quit(r *http.Request, req *QuitRequest) (*QuitReply, error)

func (*GameClient) Stats

func (gc *GameClient) Stats(r *http.Request, req *StatsRequest) (*StatsReply, error)

type GameDataReply

type GameDataReply struct {
	Token        int
	Timeout      bool
	TimeoutError string
	Data         []uint32
}

type GameDataRequest

type GameDataRequest struct {
	Token    int
	PlayerID string
}

type GameServer

type GameServer struct {
	// contains filtered or unexported fields
}

func NewGameServer

func NewGameServer(host string, port string, rpcTypeStr string, service interface{}, keepaliveDelay time.Duration, eventc chan interface{}) (*GameServer, error)

type HTTPServerExit

type HTTPServerExit struct {
	// contains filtered or unexported fields
}

type InputReply

type InputReply struct {
	Token        int
	Timeout      bool
	TimeoutError string
}

type InputRequest

type InputRequest struct {
	Token    int
	PlayerID string
	Keys     string
}

type JoinReply

type JoinReply struct {
	Token    int
	PlayerID string // uniquely identifies a joined player
}

type JoinRequest

type JoinRequest struct {
	Uid         uint32
	Name        string
	Team        string // must be "0" .. "9" or " "
	EnterStatus uint32 // any of the Q_* consts
	Ttyname     string
	ConnectMode uint32 // must be C_MESSAGE, C_PLAYER, or C_MONITOR

	Token int // passed back to client in reply
}

type KeepaliveReply

type KeepaliveReply struct {
	Seq uint64
}

type KeepaliveRequest

type KeepaliveRequest struct {
	Seq uint64
}

type MessageArgs

type MessageArgs struct {
	Message string
	Token   int
}

type MessageReply

type MessageReply struct {
	Token int
}

type MessageRequest

type MessageRequest struct {
	Token   int
	Join    JoinRequest
	Message string
}

type PingReply

type PingReply struct {
	Token int
	Seq   int
}

type PingRequest

type PingRequest struct {
	Token int
	Seq   int
}

type QuitReply

type QuitReply struct {
	Token int
}

type QuitRequest

type QuitRequest struct {
	Token    int
	PlayerID string
}

type StatsReply

type StatsReply struct {
	Token int
	Stats string
}

type StatsRequest

type StatsRequest struct {
	Token int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL