Class: GameOverseer::MessageManager

Inherits:
Object
  • Object
show all
Defined in:
lib/gameoverseer/messages/message_manager.rb

Overview

Handles sending messages to clients on behalf of services

Constant Summary collapse

MESSAGES =
[]
BROADCASTS =
[]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMessageManager

Returns a new instance of MessageManager.



8
9
10
# File 'lib/gameoverseer/messages/message_manager.rb', line 8

def initialize
  MessageManager.instance = self
end

Class Method Details

.instanceMessageManager

Returns:



31
32
33
# File 'lib/gameoverseer/messages/message_manager.rb', line 31

def self.instance
  @instance
end

.instance=(_instance) ⇒ Object

Parameters:



36
37
38
# File 'lib/gameoverseer/messages/message_manager.rb', line 36

def self.instance=_instance
  @instance = _instance
end

Instance Method Details

#broadcast(string, reliable = false, channel = ChannelManager::CHAT) ⇒ Object

Send a message to all connected clients

Parameters:

  • string (String)

    message to send

  • reliable (Boolean) (defaults to: false)

    whether or not packet delivery is reliable

  • channel (Integer) (defaults to: ChannelManager::CHAT)

    What channel to send on



26
27
28
# File 'lib/gameoverseer/messages/message_manager.rb', line 26

def broadcast(string, reliable = false, channel = ChannelManager::CHAT)
  GameOverseer::ENetServer.instance.broadcast(string, reliable, channel)
end

#message(client_id, string, reliable = false, channel = ChannelManager::CHAT) ⇒ Object

Send a message to a specific client

Parameters:

  • client_id (Integer)

    ID of client

  • string (String)

    message to send

  • reliable (Boolean) (defaults to: false)

    whether or not packet delivery is reliable

  • channel (Integer) (defaults to: ChannelManager::CHAT)

    What channel to send on



17
18
19
# File 'lib/gameoverseer/messages/message_manager.rb', line 17

def message(client_id, string, reliable = false, channel = ChannelManager::CHAT)
  GameOverseer::ENetServer.instance.transmit(client_id, string, reliable, channel)
end