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.


Build new instance of protocol


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


Tracks reconnections for debugging.


connector (Connector) – Represents the connection.

clientConnectionFailed(connector, reason)[source]

Called when Client failed to connect.

  • connector (Connection) – Represents the connection.

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

clientConnectionLost(connector, reason)[source]

Called when Client loses connection.

  • connector (Connection) – Represents the connection.

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


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.


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


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


Called when connection is established.

onMessage(payload, isBinary)[source]

Callback fired when a complete WebSocket message was received.

  • 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.

  • 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.


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


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.