goworld: github.com/xiaonanln/goworld/engine/proto Index | Files

package proto

import "github.com/xiaonanln/goworld/engine/proto"

Index

Package Files

GoWorldConnection.go proto.go

Constants

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_SOMEWHERE is a message type for creating entities
    MT_CREATE_ENTITY_SOMEWHERE
    // 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
    MT_NOTIFY_GAME_DISCONNECTED
    MT_NOTIFY_DEPLOYMENT_READY
    // MT_GAME_LBC_INFO contains game load balacing info
    MT_GAME_LBC_INFO
)
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

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
)
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
)
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

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
)

func AllocCallFilterClientProxiesPacket Uses

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

SendCallFilterClientProxies sends MT_CALL_FILTERED_CLIENTS message

func AllocCallNilSpacesPacket Uses

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

func AllocGameLBCInfoPacket Uses

func AllocGameLBCInfoPacket(lbcinfo GameLBCInfo) *netutil.Packet

func AllocStartFreezeGamePacket Uses

func AllocStartFreezeGamePacket() *netutil.Packet

func MakeNotifyDeploymentReadyPacket Uses

func MakeNotifyDeploymentReadyPacket() *netutil.Packet

func MakeNotifyGameConnectedPacket Uses

func MakeNotifyGameConnectedPacket(gameid uint16) *netutil.Packet

func MakeNotifyGameDisconnectedPacket Uses

func MakeNotifyGameDisconnectedPacket(gameid uint16) *netutil.Packet

type EntitySyncInfo Uses

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

EntitySyncInfo defines fields of entity sync info

type FilterClientsOpType Uses

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 GameLBCInfo Uses

type GameLBCInfo struct {
    CPUPercent float64 `msgpack:"cp"`
}

GameLBCInfo defines the info for game load balancing

type GoWorldConnection Uses

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

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

func NewGoWorldConnection Uses

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

NewGoWorldConnection creates a GoWorldConnection using network connection

func (*GoWorldConnection) Close Uses

func (gwc *GoWorldConnection) Close() error

Close this connection

func (*GoWorldConnection) Flush Uses

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

Flush connection writes

func (*GoWorldConnection) IsClosed Uses

func (gwc *GoWorldConnection) IsClosed() bool

IsClosed returns if the connection is closed

func (*GoWorldConnection) LocalAddr Uses

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

LocalAddr returns the local address

func (*GoWorldConnection) Recv Uses

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

Recv receives the next packet and retrive the message type

func (*GoWorldConnection) RemoteAddr Uses

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

RemoteAddr returns the remote address

func (*GoWorldConnection) SendCallEntityMethod Uses

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

SendCallEntityMethod sends MT_CALL_ENTITY_METHOD message

func (*GoWorldConnection) SendCallEntityMethodFromClient Uses

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

SendCallEntityMethodFromClient sends MT_CALL_ENTITY_METHOD_FROM_CLIENT message

func (*GoWorldConnection) SendCallEntityMethodOnClient Uses

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 Uses

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

SendCancelMigrate sends MT_CANCEL_MIGRATE message to dispatcher to unblock the entity

func (*GoWorldConnection) SendClearClientFilterProp Uses

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

SendClearClientFilterProp sends MT_CLEAR_CLIENTPROXY_FILTER_PROPS message

func (*GoWorldConnection) SendCreateEntityOnClient Uses

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) SendCreateEntitySomewhere Uses

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

SendCreateEntitySomewhere sends MT_CREATE_ENTITY_SOMEWHERE message

func (*GoWorldConnection) SendDestroyEntityOnClient Uses

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 Uses

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

SendLoadEntitySomewhere sends MT_LOAD_ENTITY_SOMEWHERE message

func (*GoWorldConnection) SendMigrateRequest Uses

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

SendMigrateRequest sends MT_MIGRATE_REQUEST message

func (*GoWorldConnection) SendNotifyClientConnected Uses

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

SendNotifyClientConnected sends MT_NOTIFY_CLIENT_CONNECTED message

func (*GoWorldConnection) SendNotifyClientDisconnected Uses

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

SendNotifyClientDisconnected sends MT_NOTIFY_CLIENT_DISCONNECTED message

func (*GoWorldConnection) SendNotifyCreateEntity Uses

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

SendNotifyCreateEntity sends MT_NOTIFY_CREATE_ENTITY message

func (*GoWorldConnection) SendNotifyDestroyEntity Uses

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

SendNotifyDestroyEntity sends MT_NOTIFY_DESTROY_ENTITY message

func (*GoWorldConnection) SendNotifyListAttrAppendOnClient Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

SendPacket send a packet to remote

func (*GoWorldConnection) SendPacketRelease Uses

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

SendPacketRelease send a packet to remote and then release the packet

func (*GoWorldConnection) SendQuerySpaceGameIDForMigrate Uses

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

SendQuerySpaceGameIDForMigrate sends MT_QUERY_SPACE_GAMEID_FOR_MIGRATE message

func (*GoWorldConnection) SendRealMigrate Uses

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

SendRealMigrate sends MT_REAL_MIGRATE message

func (*GoWorldConnection) SendSetClientFilterProp Uses

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 Uses

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 Uses

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

func (*GoWorldConnection) SendSetGateID Uses

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

SendSetGateID sends MT_SET_GATE_ID message

func (*GoWorldConnection) SendSrvdisRegister Uses

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

SendSrvdisRegister

func (*GoWorldConnection) SendSyncPositionYawFromClient Uses

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 Uses

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

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

func (*GoWorldConnection) SetHeartbeatFromClient Uses

func (gwc *GoWorldConnection) SetHeartbeatFromClient() error

func (*GoWorldConnection) SetRecvDeadline Uses

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

SetRecvDeadline set receive deadline

func (*GoWorldConnection) String Uses

func (gwc *GoWorldConnection) String() string

type Message Uses

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

type MsgType Uses

type MsgType uint16

MsgType is the type of message types

Package proto imports 9 packages (graph) and is imported by 7 packages. Updated 2018-09-14. Refresh now. Tools for package owners.