Garuda v0.2.5 Garuda.GameSocket
Defines specific game behaviours over Phoenix.Socket
GameSocket extends Phoenix.Socket with extra game behaviours.
Using GameSocket
In user_socket.ex, we can do
defmodule TictactoePhxWeb.UserSocket do
use Garuda.GameSocket
game_channel "tictactoe", TictactoePhxWeb.TictactoeChannel, TictactoePhx.TictactoeRoom
endYou might have noticed that instead of use Phoenix.Socket, we are using Garuda.GameSocket and instead of
channel, we are using game_channel.
Link to this section Summary
Functions
Defines a game-channel and corresponding game-room name.
Link to this section Functions
Defines a game-channel and corresponding game-room name.
channel_name- A game-channel name as string, ex "tictactoe"channel_module- The game-channel module handler, exTictactoePhxWeb.TictactoeChannelgame_room_module- The game-room module handler, where core game logic resides, exTictactoePhx.TictactoeRoom
Example
game_channel "tictactoe", TictactoePhxWeb.TictactoeChannel, TictactoePhx.TictactoeRoom