server

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2020 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Project OpenMonster Copyright (C) 2020 Kori

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/\>.

Project OpenMonster Copyright (C) 2020 Kori

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/\>.

Project OpenMonster Copyright (C) 2020 Kori

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/\>.

Project OpenMonster Copyright (C) 2020 Kori

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/\>.

Project OpenMonster Copyright (C) 2020 Kori

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/\>.

Index

Constants

This section is empty.

Variables

View Source
var FillContext func(ctx context.Context) context.Context

Functions

func Start

func Start()

Types

type ErrorCode

type ErrorCode string

type Message

type Message struct {
	Type       string          `json:"type"`
	ID         int             `json:"id"`
	ResponseID int             `json:"responseID,omitempty"`
	Data       json.RawMessage `json:"data"`
}

Message is the container for messages send to or received from the client. It contains the type, an id and the data. If the Message is a response to another message, ResponseID will contain the id of the first message.

type MessageHandler

type MessageHandler func(context.Context, Message, MessageWriter, Session) error

MessageHandler parse the message data and act according to the data.

If an error occurs, the user should be notified. If the error was caused by the user, like referencing an unknown user, no error should be returned. Returns an error, if a connection problem, a database error or similiar server-side errors appear.

func Authenticated

func Authenticated(handler MessageHandler) MessageHandler

type MessageWriter

type MessageWriter interface {
	// TODO: Maybe remove messageType
	// WebSocket connections should always use TextMessage
	WriteMessage(messageType int, data []byte) error
}

type Overworld added in v0.4.0

type Overworld interface {
	AddPlayer(breederID model.ID, commands chan overworld.Command, updates chan overworld.Update) (uint64, error)
}

type Session

type Session map[string]interface{}

Jump to

Keyboard shortcuts

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