using UnityEngine.Networking;
using UnityEngine;
//This is where you can type out all the message types you want
//(these can not be attached to a game object or have any sort of physical existence without a codehost).
//It is not necessary to have a separate script for these, but it makes it more tidy and easier to edit and come back to.s
//Declaring the namespace all my scripts are found under
namespace Panzerwolf
{
//Declaring the ChatMsg class, making it public so it can be referred to by the other scripts required for chatting.
public class ChatMsg
{
//These numbers are a vital part of how the networkmessage system works.
//When a NetworkMessage is sent, it gets received by all handlers present on a connection.
//This is why all NetworkMessages have an identifier(short int) that all handlers will check for,
//as a handler have no way of knowing a networkmessage contains.
public const short ChannelJoin = 100;
public const short ChannelLeave = 101;
public const short Talk = 102;
public const short Login = 103;
public const short Logoff = 104;
public const short ChannelCreate = 105;
public const short ChannelFailed = 106;
}
//All message types must derive from MessageBase to be sent using NetworkMessage
public class LogoffMessage : MessageBase
{
//This is what a NetworkMessage of type "LogoffMessage" contains
public ChatPersonId personId;
}
public class ChannelJoinFailedMessage : MessageBase
{
//It can be null and the respective handler of the NetworkMessage identifier
//will still receive and run its code.
}
public class ChannelJoinRequestMessage : MessageBase
{
//To send the server a request to join a channel,
//all we need is the id of the person on the server(ChatPersonID)
//and the name of the channel we are trying to join.
public ChatPersonId personId;
public string name;
}
public class ChannelJoinResponseMessage : MessageBase
{
//This is the response message a server will send back
//to the client.
//Here we can add information about a channel
//that we want the client to receive.
public ChatPersonId personId;
public ChatChannelId channelId;
//The name of the channel
public string channelName;
//The alias of the channel
public string channelAlias;
//The name of the person joining
public string personName;
//The color code of the channel(related to alias)
public Color channelColor;
}
//This is a request a client can send to the server to create their own channel
//**NOT USED**
public class ChannelCreateMessage : MessageBase
{
public ChatPersonId personId;
public string channelName;
}
//This is the response from the server to a client trying to create their own channel
//**NOT USED**
public class ChannelCreateResponseMessage : MessageBase
{
public ChatPersonId personId;
public string channelName;
public ChatChannelId channelId;
}
//This is the message the client sends to the server to be removed from the channel we want to leaves "people" list
public class ChannelLeaveRequestMessage : MessageBase
{
public ChatPersonId personId;
public ChatChannelId channelId;
}
//Response to above
public class ChannelLeaveResponseMessage : MessageBase
{
public ChatPersonId personId;
public ChatChannelId channelId;
}
//This is the message type we use for chatting.
public class TalkMessage : MessageBase
{
//The id of the person sending the chat
public ChatPersonId personId;
//The id of the channel the person is sending the chat to
public ChatChannelId channelId;
//The chat message itself
public string text;
//The counter for how many messages have been sent total.
//This is used for lack of a better way to allow writing
//the same message(i.e. "Yes" and "Yes") so both messages
//will have an unique identifier.
public int count;
}
//These should be self explanatory by now
public class LoginMessage : MessageBase
{
public string personName;
}
public class LoginResponseMessage : MessageBase
{
public string personName;
public ChatPersonId personId;
}
//**NOT USED**
//We don't need the client to get any info like this,
//as I would more than likely only use this to build
//a list of channels on the clients end.
public struct ChannelInfo
{
public ChatChannelId channelId;
public string channelName;
}
}