evennia.server.portal.grapevine

Grapevine network connection

This is an implementation of the Grapevine Websocket protocol v 1.0.0 as outlined here: https://grapevine.haus/docs

This will allow the linked game to transfer status as well as connects the grapevine client to in-game channels.

class evennia.server.portal.grapevine.RestartingWebsocketServerFactory(sessionhandler, *args, **kwargs)[source]

Bases: autobahn.twisted.websocket.WebSocketClientFactory, twisted.internet.protocol.ReconnectingClientFactory

A variant of the websocket-factory that auto-reconnects.

initialDelay = 1
factor = 1.5
maxDelay = 60
__init__(sessionhandler, *args, **kwargs)[source]

In addition to all arguments to the constructor of :func:autobahn.websocket.interfaces.IWebSocketClientChannelFactory, you can supply a **reactor** keyword argument to specify the Twisted reactor to be used.

buildProtocol(addr)[source]

Build new instance of protocol

Parameters

addr (str) – Not used, using factory/settings data

startedConnecting(connector)[source]

Tracks reconnections for debugging.

Parameters

connector (Connector) – Represents the connection.

clientConnectionFailed(connector, reason)[source]

Called when Client failed to connect.

Parameters
  • connector (Connection) – Represents the connection.

  • reason (str) – The reason for the failure.

clientConnectionLost(connector, reason)[source]

Called when Client loses connection.

Parameters
  • connector (Connection) – Represents the connection.

  • reason (str) – The reason for the failure.

reconnect()[source]

Force a reconnection of the bot protocol. This requires de-registering the session and then reattaching a new one, otherwise you end up with an ever growing number of bot sessions.

start()[source]

Connect protocol to remote server

class evennia.server.portal.grapevine.GrapevineClient[source]

Bases: autobahn.twisted.websocket.WebSocketClientProtocol, evennia.server.session.Session

Implements the grapevine client

__init__()[source]

Initialize self. See help(type(self)) for accurate signature.

at_login()[source]
onOpen()[source]

Called when connection is established.

onMessage(payload, isBinary)[source]

Callback fired when a complete WebSocket message was received.

Parameters
  • payload (bytes) – The WebSocket message received.

  • isBinary (bool) – Flag indicating whether payload is binary or UTF-8 encoded text.

onClose(wasClean, code=None, reason=None)[source]

This is executed when the connection is lost for whatever reason. it can also be called directly, from the disconnect method.

Parameters
  • wasClean (bool) – **True** if the WebSocket was closed cleanly.

  • code (int or None) – Close status as sent by the WebSocket peer.

  • reason (str or None) – Close reason as sent by the WebSocket peer.

disconnect(reason=None)[source]

Generic hook for the engine to call in order to disconnect this protocol.

Parameters

reason (str or None) – Motivation for the disconnection.

send_authenticate(*args, **kwargs)[source]

Send grapevine authentication. This should be send immediately upon connection.

send_heartbeat(*args, **kwargs)[source]

Send heartbeat to remote grapevine server.

send_subscribe(channelname, *args, **kwargs)[source]

Subscribe to new grapevine channel

Use with session.msg(subscribe=”channelname”)

send_unsubscribe(channelname, *args, **kwargs)[source]

Un-subscribe to a grapevine channel

Use with session.msg(unsubscribe=”channelname”)

send_channel(text, channel, sender, *args, **kwargs)[source]

Send text type Evennia -> grapevine

This is the channels/send message type

Use with session.msg(channel=(message, channel, sender))

send_default(*args, **kwargs)[source]

Ignore other outputfuncs

data_in(data, **kwargs)[source]

Send data grapevine -> Evennia

Keyword Arguments

data (dict) – Converted json data.