fork download
  1. using UnityEngine.Networking;
  2. using UnityEngine;
  3.  
  4.  
  5. //This is where you can type out all the message types you want
  6. //(these can not be attached to a game object or have any sort of physical existence without a codehost).
  7.  
  8. //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
  9.  
  10.  
  11. //Declaring the namespace all my scripts are found under
  12. namespace Panzerwolf
  13. {
  14. //Declaring the ChatMsg class, making it public so it can be referred to by the other scripts required for chatting.
  15. public class ChatMsg
  16. {
  17. //These numbers are a vital part of how the networkmessage system works.
  18. //When a NetworkMessage is sent, it gets received by all handlers present on a connection.
  19.  
  20. //This is why all NetworkMessages have an identifier(short int) that all handlers will check for,
  21. //as a handler have no way of knowing a networkmessage contains.
  22.  
  23. public const short ChannelJoin = 100;
  24. public const short ChannelLeave = 101;
  25. public const short Talk = 102;
  26. public const short Login = 103;
  27. public const short Logoff = 104;
  28. public const short ChannelCreate = 105;
  29. public const short ChannelFailed = 106;
  30. }
  31.  
  32.  
  33. //All message types must derive from MessageBase to be sent using NetworkMessage
  34. public class LogoffMessage : MessageBase
  35. {
  36. //This is what a NetworkMessage of type "LogoffMessage" contains
  37.  
  38. public ChatPersonId personId;
  39. }
  40.  
  41. public class ChannelJoinFailedMessage : MessageBase
  42. {
  43. //It can be null and the respective handler of the NetworkMessage identifier
  44. //will still receive and run its code.
  45. }
  46.  
  47. public class ChannelJoinRequestMessage : MessageBase
  48. {
  49. //To send the server a request to join a channel,
  50. //all we need is the id of the person on the server(ChatPersonID)
  51. //and the name of the channel we are trying to join.
  52.  
  53. public ChatPersonId personId;
  54. public string name;
  55. }
  56.  
  57. public class ChannelJoinResponseMessage : MessageBase
  58. {
  59. //This is the response message a server will send back
  60. //to the client.
  61.  
  62. //Here we can add information about a channel
  63. //that we want the client to receive.
  64. public ChatPersonId personId;
  65. public ChatChannelId channelId;
  66.  
  67. //The name of the channel
  68. public string channelName;
  69.  
  70. //The alias of the channel
  71. public string channelAlias;
  72.  
  73. //The name of the person joining
  74. public string personName;
  75.  
  76. //The color code of the channel(related to alias)
  77. public Color channelColor;
  78. }
  79.  
  80.  
  81. //This is a request a client can send to the server to create their own channel
  82. //**NOT USED**
  83. public class ChannelCreateMessage : MessageBase
  84. {
  85. public ChatPersonId personId;
  86. public string channelName;
  87. }
  88.  
  89. //This is the response from the server to a client trying to create their own channel
  90. //**NOT USED**
  91. public class ChannelCreateResponseMessage : MessageBase
  92. {
  93. public ChatPersonId personId;
  94. public string channelName;
  95. public ChatChannelId channelId;
  96. }
  97.  
  98. //This is the message the client sends to the server to be removed from the channel we want to leaves "people" list
  99. public class ChannelLeaveRequestMessage : MessageBase
  100. {
  101. public ChatPersonId personId;
  102. public ChatChannelId channelId;
  103. }
  104.  
  105.  
  106. //Response to above
  107. public class ChannelLeaveResponseMessage : MessageBase
  108. {
  109. public ChatPersonId personId;
  110. public ChatChannelId channelId;
  111. }
  112.  
  113.  
  114. //This is the message type we use for chatting.
  115. public class TalkMessage : MessageBase
  116. {
  117. //The id of the person sending the chat
  118. public ChatPersonId personId;
  119.  
  120. //The id of the channel the person is sending the chat to
  121. public ChatChannelId channelId;
  122.  
  123. //The chat message itself
  124. public string text;
  125.  
  126. //The counter for how many messages have been sent total.
  127. //This is used for lack of a better way to allow writing
  128. //the same message(i.e. "Yes" and "Yes") so both messages
  129. //will have an unique identifier.
  130. public int count;
  131. }
  132.  
  133.  
  134. //These should be self explanatory by now
  135. public class LoginMessage : MessageBase
  136. {
  137. public string personName;
  138. }
  139.  
  140. public class LoginResponseMessage : MessageBase
  141. {
  142. public string personName;
  143. public ChatPersonId personId;
  144. }
  145.  
  146.  
  147. //**NOT USED**
  148. //We don't need the client to get any info like this,
  149. //as I would more than likely only use this to build
  150. //a list of channels on the clients end.
  151. public struct ChannelInfo
  152. {
  153. public ChatChannelId channelId;
  154. public string channelName;
  155. }
  156.  
  157. }
  158.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,7): error CS0246: The type or namespace name `UnityEngine' could not be found. Are you missing an assembly reference?
prog.cs(2,7): error CS0246: The type or namespace name `UnityEngine' could not be found. Are you missing an assembly reference?
prog.cs(34,31): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(41,42): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(47,43): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(57,44): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(83,38): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(91,46): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(99,44): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(107,45): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(115,29): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(135,30): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(140,38): error CS0246: The type or namespace name `MessageBase' could not be found. Are you missing an assembly reference?
prog.cs(38,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(53,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(64,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(65,10): error CS0246: The type or namespace name `ChatChannelId' could not be found. Are you missing an assembly reference?
prog.cs(77,10): error CS0246: The type or namespace name `Color' could not be found. Are you missing `System.Drawing' using directive?
prog.cs(85,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(93,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(95,10): error CS0246: The type or namespace name `ChatChannelId' could not be found. Are you missing an assembly reference?
prog.cs(101,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(102,10): error CS0246: The type or namespace name `ChatChannelId' could not be found. Are you missing an assembly reference?
prog.cs(109,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(110,10): error CS0246: The type or namespace name `ChatChannelId' could not be found. Are you missing an assembly reference?
prog.cs(118,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(121,10): error CS0246: The type or namespace name `ChatChannelId' could not be found. Are you missing an assembly reference?
prog.cs(143,10): error CS0246: The type or namespace name `ChatPersonId' could not be found. Are you missing an assembly reference?
prog.cs(153,10): error CS0246: The type or namespace name `ChatChannelId' could not be found. Are you missing an assembly reference?
Compilation failed: 29 error(s), 0 warnings
stdout
Standard output is empty