C# Class ChatGui, TLH

Simple Chat Server Gui to be put on a separate GameObject. Provides a global chat (in lobby) and a room chat (in room).
This script flags it's GameObject with DontDestroyOnLoad(). Make sure this is OK in your case. The Chat Server API in ChatClient basically lets you create any number of channels. You just have to name them. Example: "gc" for Global Channel or for rooms: "rc"+RoomName.GetHashCode() This simple demo sends in a global chat when in lobby and in room channel when in room. Create a more elaborate UI to let players chat in either channel while in room or send private messages. Names of users are set in Authenticate. That should be unique so users can actually get their messages. Workflow: Create ChatClient, Connect to a server with your AppID, Authenticate the user (apply a unique name) and subscribe to some channels. Subscribe a channel before you publish to that channel! Note: Don't forget to call ChatClient.Service(). Might later on be integrated into PUN but for now don't forget.
Inheritance: MonoBehaviour, IChatClientListener
Show file Open project: hydrater/TLH Class Usage Examples

Public Properties

Property Type Description
AlignBottom bool
ChannelsToJoinOnConnect string[]
ChatAppId string
DemoPublishOnSubscribe bool
FullScreen bool
GuiRect Rect
HistoryLengthToFetch int
IsVisible bool
chatClient ChatClient

Public Methods

Method Description
Awake ( ) : void
DebugReturn ( DebugLevel, level, string message ) : void
OnApplicationQuit ( ) : void

To avoid the Editor becoming unresponsive, disconnect all Photon connections in OnApplicationQuit.

OnChatStateChange ( ChatState state ) : void
OnConnected ( ) : void
OnDestroy ( ) : void

To avoid the Editor becoming unresponsive, disconnect the Chat connection.

OnDisconnected ( ) : void
OnEnable ( ) : void
OnGUI ( ) : void
OnGetMessages ( string channelName, string senders, object messages ) : void
OnPrivateMessage ( string sender, object message, string channelName ) : void
OnStatusUpdate ( string user, int status, bool gotMessage, object message ) : void
OnSubscribed ( string channels, bool results ) : void
OnUnsubscribed ( string channels ) : void
Start ( ) : void
Update ( ) : void

Private Methods

Method Description
GuiSendsMsg ( ) : void
PostHelpToCurrentChannel ( ) : void

Method Details

Awake() public method

public Awake ( ) : void
return void

DebugReturn() public method

public DebugReturn ( DebugLevel, level, string message ) : void
level DebugLevel,
message string
return void

OnApplicationQuit() public method

To avoid the Editor becoming unresponsive, disconnect all Photon connections in OnApplicationQuit.
public OnApplicationQuit ( ) : void
return void

OnChatStateChange() public method

public OnChatStateChange ( ChatState state ) : void
state ChatState
return void

OnConnected() public method

public OnConnected ( ) : void
return void

OnDestroy() public method

To avoid the Editor becoming unresponsive, disconnect the Chat connection.
public OnDestroy ( ) : void
return void

OnDisconnected() public method

public OnDisconnected ( ) : void
return void

OnEnable() public method

public OnEnable ( ) : void
return void

OnGUI() public method

public OnGUI ( ) : void
return void

OnGetMessages() public method

public OnGetMessages ( string channelName, string senders, object messages ) : void
channelName string
senders string
messages object
return void

OnPrivateMessage() public method

public OnPrivateMessage ( string sender, object message, string channelName ) : void
sender string
message object
channelName string
return void

OnStatusUpdate() public method

public OnStatusUpdate ( string user, int status, bool gotMessage, object message ) : void
user string
status int
gotMessage bool
message object
return void

OnSubscribed() public method

public OnSubscribed ( string channels, bool results ) : void
channels string
results bool
return void

OnUnsubscribed() public method

public OnUnsubscribed ( string channels ) : void
channels string
return void

Start() public method

public Start ( ) : void
return void

Update() public method

public Update ( ) : void
return void

Property Details

AlignBottom public property

public bool AlignBottom
return bool

ChannelsToJoinOnConnect public property

public string[] ChannelsToJoinOnConnect
return string[]

ChatAppId public property

public string ChatAppId
return string

DemoPublishOnSubscribe public property

public bool DemoPublishOnSubscribe
return bool

FullScreen public property

public bool FullScreen
return bool

GuiRect public property

public Rect GuiRect
return Rect

HistoryLengthToFetch public property

public int HistoryLengthToFetch
return int

IsVisible public property

public bool IsVisible
return bool

chatClient public property

public ChatClient chatClient
return ChatClient