proto

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MT_INVALID is the invalid message type
	MT_INVALID = iota
	// MT_SET_GAME_ID is a message type for game
	MT_SET_GAME_ID
	// MT_SET_GATE_ID is a message type for gate
	MT_SET_GATE_ID
	// MT_NOTIFY_CREATE_ENTITY is a message type for creating entities
	MT_NOTIFY_CREATE_ENTITY
	// MT_NOTIFY_DESTROY_ENTITY is a message type for destroying entities
	MT_NOTIFY_DESTROY_ENTITY
	// MT_SRVDIS_REGISTER is a message type for declaring services
	MT_SRVDIS_REGISTER
	// MT_UNDECLARE_SERVICE is a message type for undeclaring services
	MT_UNDECLARE_SERVICE
	// MT_CALL_ENTITY_METHOD is a message type for calling entity methods
	MT_CALL_ENTITY_METHOD
	// MT_CREATE_ENTITY_ANYWHERE is a message type for creating entities
	MT_CREATE_ENTITY_ANYWHERE
	// MT_LOAD_ENTITY_SOMEWHERE is a message type loading entities
	MT_LOAD_ENTITY_SOMEWHERE
	// MT_NOTIFY_CLIENT_CONNECTED is a message type for clients
	MT_NOTIFY_CLIENT_CONNECTED
	// MT_NOTIFY_CLIENT_DISCONNECTED is a message type for clients
	MT_NOTIFY_CLIENT_DISCONNECTED
	// MT_CALL_ENTITY_METHOD_FROM_CLIENT is a message type for clients
	MT_CALL_ENTITY_METHOD_FROM_CLIENT
	// MT_SYNC_POSITION_YAW_FROM_CLIENT is a message type for clients
	MT_SYNC_POSITION_YAW_FROM_CLIENT
	// MT_NOTIFY_ALL_GAMES_CONNECTED is a message type to notify all games connected
	MT_NOTIFY_ALL_GAMES_CONNECTED // NOT USED ANYMORE
	// MT_NOTIFY_GATE_DISCONNECTED is a message type to notify gate disconnected
	MT_NOTIFY_GATE_DISCONNECTED
	// MT_START_FREEZE_GAME is a message type for hot swapping
	MT_START_FREEZE_GAME
	// MT_START_FREEZE_GAME_ACK is a message type for hot swapping
	MT_START_FREEZE_GAME_ACK

	// Message types for migrating
	// MT_MIGRATE_REQUEST is a message type for entity migrations
	MT_MIGRATE_REQUEST
	// MT_REAL_MIGRATE is a message type for entity migrations
	MT_REAL_MIGRATE
	// MT_QUERY_SPACE_GAMEID_FOR_MIGRATE is a message type for entity migrations
	MT_QUERY_SPACE_GAMEID_FOR_MIGRATE
	MT_CANCEL_MIGRATE

	// MT_CALL_NIL_SPACES message is used to call nil spaces on all games
	MT_CALL_NIL_SPACES
	// MT_SET_GAME_ID_ACK is sent by dispatcher to game to ACK MT_SET_GAME_ID message
	MT_SET_GAME_ID_ACK
	// MT_NOTIFY_GAME_CONNECTED is sent by dispatcher to game to notify new game connected
	MT_NOTIFY_GAME_CONNECTED
)
View Source
const (
	// MT_MIGRATE_REQUEST_ACK is a message type for entity migrations
	MT_MIGRATE_REQUEST_ACK                = MT_MIGRATE_REQUEST
	MT_QUERY_SPACE_GAMEID_FOR_MIGRATE_ACK = MT_QUERY_SPACE_GAMEID_FOR_MIGRATE
)

Alias message types

View Source
const (
	// MT_GATE_SERVICE_MSG_TYPE_START is the first message types that should be handled by GateService
	MT_GATE_SERVICE_MSG_TYPE_START = 1000 + iota
	// MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_START is the first message type that should be redirected to client proxy
	MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_START
	// MT_CREATE_ENTITY_ON_CLIENT message type
	MT_CREATE_ENTITY_ON_CLIENT
	// MT_DESTROY_ENTITY_ON_CLIENT message type
	MT_DESTROY_ENTITY_ON_CLIENT
	// MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT message type
	MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT
	// MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT message type
	MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT
	// MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT message type
	MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT
	// MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT message type
	MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT
	// MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT message type
	MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT
	// MT_CALL_ENTITY_METHOD_ON_CLIENT message type
	MT_CALL_ENTITY_METHOD_ON_CLIENT
	// MT_SET_CLIENTPROXY_FILTER_PROP message type
	MT_SET_CLIENTPROXY_FILTER_PROP
	// MT_CLEAR_CLIENTPROXY_FILTER_PROPS message type
	MT_CLEAR_CLIENTPROXY_FILTER_PROPS
	// MT_NOTIFY_MAP_ATTR_CLEAR_ON_CLIENT message type
	MT_NOTIFY_MAP_ATTR_CLEAR_ON_CLIENT
	// MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_STOP message type
	MT_REDIRECT_TO_GATEPROXY_MSG_TYPE_STOP = 1499
)
View Source
const (
	// MT_CALL_FILTERED_CLIENTS message type: messages to be processed by GateService from Dispatcher, but not redirected to clients
	MT_CALL_FILTERED_CLIENTS = 1501 + iota
	// MT_SYNC_POSITION_YAW_ON_CLIENTS message type
	MT_SYNC_POSITION_YAW_ON_CLIENTS
	// MT_GATE_SERVICE_MSG_TYPE_STOP message type
	MT_GATE_SERVICE_MSG_TYPE_STOP = 1999
)
View Source
const (
	// MT_SET_CLIENT_CLIENTID message is sent to client to set its clientid
	MT_SET_CLIENT_CLIENTID = 2001 + iota
	MT_UDP_SYNC_CONN_NOTIFY_CLIENTID
	MT_UDP_SYNC_CONN_NOTIFY_CLIENTID_ACK
	// MT_HEARTBEAT_FROM_CLIENT is sent by client to notify the gate server that the client is alive
	MT_HEARTBEAT_FROM_CLIENT
)

Messages types that is sent directly between Gate & Client

View Source
const (
	// SYNC_INFO_SIZE_PER_ENTITY is the size of sync info per entity
	SYNC_INFO_SIZE_PER_ENTITY = 16
	UDP_SYNC_PACKET_SIZE      = common.ENTITYID_LENGTH + SYNC_INFO_SIZE_PER_ENTITY
)

Variables

This section is empty.

Functions

func AllocCallFilterClientProxiesPacket added in v0.1.4

func AllocCallFilterClientProxiesPacket(op FilterClientsOpType, key, val string, method string, args []interface{}) *netutil.Packet

SendCallFilterClientProxies sends MT_CALL_FILTERED_CLIENTS message

func AllocCallNilSpacesPacket added in v0.1.4

func AllocCallNilSpacesPacket(exceptGameID uint16, method string, args []interface{}) *netutil.Packet

func AllocStartFreezeGamePacket added in v0.1.4

func AllocStartFreezeGamePacket() *netutil.Packet

func MakeNotifyGameConnectedPacket added in v0.1.4

func MakeNotifyGameConnectedPacket(gameid uint16) *netutil.Packet

Types

type EntitySyncInfo

type EntitySyncInfo struct {
	X, Y, Z float32
	Yaw     float32
}

EntitySyncInfo defines fields of entity sync info

type FilterClientsOpType added in v0.1.3

type FilterClientsOpType byte

Operators for calling filtered clients

const (
	FILTER_CLIENTS_OP_EQ FilterClientsOpType = iota
	FILTER_CLIENTS_OP_NE
	FILTER_CLIENTS_OP_GT
	FILTER_CLIENTS_OP_LT
	FILTER_CLIENTS_OP_GTE
	FILTER_CLIENTS_OP_LTE
)

type GoWorldConnection

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

GoWorldConnection is the network protocol implementation of GoWorld components (dispatcher, gate, game)

func NewGoWorldConnection

func NewGoWorldConnection(conn netutil.Connection, compressConnection bool, compressFormat string) *GoWorldConnection

NewGoWorldConnection creates a GoWorldConnection using network connection

func (*GoWorldConnection) Close

func (gwc *GoWorldConnection) Close() error

Close this connection

func (*GoWorldConnection) Flush

func (gwc *GoWorldConnection) Flush(reason string) error

Flush connection writes

func (*GoWorldConnection) IsClosed

func (gwc *GoWorldConnection) IsClosed() bool

IsClosed returns if the connection is closed

func (*GoWorldConnection) LocalAddr

func (gwc *GoWorldConnection) LocalAddr() net.Addr

LocalAddr returns the local address

func (*GoWorldConnection) Recv

func (gwc *GoWorldConnection) Recv(msgtype *MsgType) (*netutil.Packet, error)

Recv receives the next packet and retrive the message type

func (*GoWorldConnection) RemoteAddr

func (gwc *GoWorldConnection) RemoteAddr() net.Addr

RemoteAddr returns the remote address

func (*GoWorldConnection) SendCallEntityMethod

func (gwc *GoWorldConnection) SendCallEntityMethod(id common.EntityID, method string, args []interface{}) error

SendCallEntityMethod sends MT_CALL_ENTITY_METHOD message

func (*GoWorldConnection) SendCallEntityMethodFromClient

func (gwc *GoWorldConnection) SendCallEntityMethodFromClient(id common.EntityID, method string, args []interface{}) error

SendCallEntityMethodFromClient sends MT_CALL_ENTITY_METHOD_FROM_CLIENT message

func (*GoWorldConnection) SendCallEntityMethodOnClient

func (gwc *GoWorldConnection) SendCallEntityMethodOnClient(gateid uint16, clientid common.ClientID, entityID common.EntityID, method string, args []interface{}) (err error)

SendCallEntityMethodOnClient sends MT_CALL_ENTITY_METHOD_ON_CLIENT message

func (*GoWorldConnection) SendCancelMigrate added in v0.1.3

func (gwc *GoWorldConnection) SendCancelMigrate(entityid common.EntityID) error

SendCancelMigrate sends MT_CANCEL_MIGRATE message to dispatcher to unblock the entity

func (*GoWorldConnection) SendClearClientFilterProp

func (gwc *GoWorldConnection) SendClearClientFilterProp(gateid uint16, clientid common.ClientID) (err error)

SendClearClientFilterProp sends MT_CLEAR_CLIENTPROXY_FILTER_PROPS message

func (*GoWorldConnection) SendCreateEntityAnywhere

func (gwc *GoWorldConnection) SendCreateEntityAnywhere(entityid common.EntityID, typeName string, data map[string]interface{}) error

SendCreateEntityAnywhere sends MT_CREATE_ENTITY_ANYWHERE message

func (*GoWorldConnection) SendCreateEntityOnClient

func (gwc *GoWorldConnection) SendCreateEntityOnClient(gameid uint16, clientid common.ClientID, typeName string, entityid common.EntityID,
	isPlayer bool, clientData map[string]interface{}, x, y, z float32, yaw float32) error

SendCreateEntityOnClient sends MT_CREATE_ENTITY_ON_CLIENT message

func (*GoWorldConnection) SendDestroyEntityOnClient

func (gwc *GoWorldConnection) SendDestroyEntityOnClient(gateid uint16, clientid common.ClientID, typeName string, entityid common.EntityID) error

SendDestroyEntityOnClient sends MT_DESTROY_ENTITY_ON_CLIENT message

func (*GoWorldConnection) SendLoadEntitySomewhere added in v0.1.4

func (gwc *GoWorldConnection) SendLoadEntitySomewhere(typeName string, entityID common.EntityID, gameid uint16) error

SendLoadEntitySomewhere sends MT_LOAD_ENTITY_SOMEWHERE message

func (*GoWorldConnection) SendMigrateRequest

func (gwc *GoWorldConnection) SendMigrateRequest(entityID common.EntityID, spaceID common.EntityID, spaceGameID uint16) error

SendMigrateRequest sends MT_MIGRATE_REQUEST message

func (*GoWorldConnection) SendNotifyClientConnected

func (gwc *GoWorldConnection) SendNotifyClientConnected(id common.ClientID) error

SendNotifyClientConnected sends MT_NOTIFY_CLIENT_CONNECTED message

func (*GoWorldConnection) SendNotifyClientDisconnected

func (gwc *GoWorldConnection) SendNotifyClientDisconnected(id common.ClientID) error

SendNotifyClientDisconnected sends MT_NOTIFY_CLIENT_DISCONNECTED message

func (*GoWorldConnection) SendNotifyCreateEntity

func (gwc *GoWorldConnection) SendNotifyCreateEntity(id common.EntityID) error

SendNotifyCreateEntity sends MT_NOTIFY_CREATE_ENTITY message

func (*GoWorldConnection) SendNotifyDestroyEntity

func (gwc *GoWorldConnection) SendNotifyDestroyEntity(id common.EntityID) error

SendNotifyDestroyEntity sends MT_NOTIFY_DESTROY_ENTITY message

func (*GoWorldConnection) SendNotifyListAttrAppendOnClient

func (gwc *GoWorldConnection) SendNotifyListAttrAppendOnClient(gateid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, val interface{}) error

SendNotifyListAttrAppendOnClient sends MT_NOTIFY_LIST_ATTR_APPEND_ON_CLIENT message

func (*GoWorldConnection) SendNotifyListAttrChangeOnClient

func (gwc *GoWorldConnection) SendNotifyListAttrChangeOnClient(gateid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, index uint32, val interface{}) error

SendNotifyListAttrChangeOnClient sends MT_NOTIFY_LIST_ATTR_CHANGE_ON_CLIENT message

func (*GoWorldConnection) SendNotifyListAttrPopOnClient

func (gwc *GoWorldConnection) SendNotifyListAttrPopOnClient(gateid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}) error

SendNotifyListAttrPopOnClient sends MT_NOTIFY_LIST_ATTR_POP_ON_CLIENT message

func (*GoWorldConnection) SendNotifyMapAttrChangeOnClient

func (gwc *GoWorldConnection) SendNotifyMapAttrChangeOnClient(gateid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, key string, val interface{}) error

SendNotifyMapAttrChangeOnClient sends MT_NOTIFY_MAP_ATTR_CHANGE_ON_CLIENT message

func (*GoWorldConnection) SendNotifyMapAttrClearOnClient added in v0.1.4

func (gwc *GoWorldConnection) SendNotifyMapAttrClearOnClient(gateid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}) error

SendNotifyMapAttrClearOnClient sends MT_NOTIFY_MAP_ATTR_CLEAR_ON_CLIENT message

func (*GoWorldConnection) SendNotifyMapAttrDelOnClient

func (gwc *GoWorldConnection) SendNotifyMapAttrDelOnClient(gateid uint16, clientid common.ClientID, entityid common.EntityID, path []interface{}, key string) error

SendNotifyMapAttrDelOnClient sends MT_NOTIFY_MAP_ATTR_DEL_ON_CLIENT message

func (*GoWorldConnection) SendPacket

func (gwc *GoWorldConnection) SendPacket(packet *netutil.Packet) error

SendPacket send a packet to remote

func (*GoWorldConnection) SendPacketRelease

func (gwc *GoWorldConnection) SendPacketRelease(packet *netutil.Packet) error

SendPacketRelease send a packet to remote and then release the packet

func (*GoWorldConnection) SendQuerySpaceGameIDForMigrate added in v0.1.2

func (gwc *GoWorldConnection) SendQuerySpaceGameIDForMigrate(spaceid common.EntityID, entityid common.EntityID) error

SendQuerySpaceGameIDForMigrate sends MT_QUERY_SPACE_GAMEID_FOR_MIGRATE message

func (*GoWorldConnection) SendRealMigrate

func (gwc *GoWorldConnection) SendRealMigrate(eid common.EntityID, targetGame uint16, data []byte) error

SendRealMigrate sends MT_REAL_MIGRATE message

func (*GoWorldConnection) SendSetClientFilterProp

func (gwc *GoWorldConnection) SendSetClientFilterProp(gateid uint16, clientid common.ClientID, key, val string) (err error)

SendSetClientFilterProp sends MT_SET_CLIENTPROXY_FILTER_PROP message

func (*GoWorldConnection) SendSetGameID

func (gwc *GoWorldConnection) SendSetGameID(id uint16, isReconnect bool, isRestore bool, isBanBootEntity bool,
	eids []common.EntityID) error

SendSetGameID sends MT_SET_GAME_ID message

func (*GoWorldConnection) SendSetGameIDAck added in v0.1.4

func (gwc *GoWorldConnection) SendSetGameIDAck(dispid uint16, connectedGameIDs []uint16, rejectEntities []common.EntityID, srvdisRegisterMap map[string]string) error

func (*GoWorldConnection) SendSetGateID

func (gwc *GoWorldConnection) SendSetGateID(id uint16) error

SendSetGateID sends MT_SET_GATE_ID message

func (*GoWorldConnection) SendSrvdisRegister added in v0.1.4

func (gwc *GoWorldConnection) SendSrvdisRegister(srvid string, info string, force bool) error

SendSrvdisRegister

func (*GoWorldConnection) SendSyncPositionYawFromClient

func (gwc *GoWorldConnection) SendSyncPositionYawFromClient(entityID common.EntityID, x, y, z float32, yaw float32) error

SendSyncPositionYawFromClient sends MT_SYNC_POSITION_YAW_FROM_CLIENT message

func (*GoWorldConnection) SetAutoFlush

func (gwc *GoWorldConnection) SetAutoFlush(interval time.Duration)

SetAutoFlush starts a goroutine to flush connection writes at some specified interval

func (*GoWorldConnection) SetHeartbeatFromClient

func (gwc *GoWorldConnection) SetHeartbeatFromClient() error

func (*GoWorldConnection) SetRecvDeadline

func (gwc *GoWorldConnection) SetRecvDeadline(deadline time.Time) error

SetRecvDeadline set receive deadline

func (*GoWorldConnection) String

func (gwc *GoWorldConnection) String() string

type Message added in v0.1.2

type Message struct {
	MsgType MsgType
	Packet  *netutil.Packet
}

type MsgType

type MsgType uint16

MsgType is the type of message types

Jump to

Keyboard shortcuts

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