Esempio n. 1
0
 public UntypedCmdConverter(UntypedCmdEventHandler handler)
 {
     m_handler = handler;
 }
Esempio n. 2
0
 public UntypedCmdConverter(HFTLog log, UntypedCmdEventHandler handler)
 {
     m_log     = log;
     m_handler = handler;
 }
Esempio n. 3
0
        /// <summary>
        /// <![CDATA[
        /// Lets you register a command to be called when the game is directly sent a message.
        ///
        /// This the most low-level basic version of RegisterCmdHandler. The function registered
        /// will be called with a Dictionary<string, object> with whatever data is passed in.
        /// You can either pull the data out directly OR you can call Deserializer.Deserilize
        /// with a type and have the data extracted for you.
        /// ]]>
        /// </summary>
        /// <example>
        /// <code>
        /// <![CDATA[
        /// ...
        /// gameServer.RegisterCmdHandler("color", OnColor);
        /// ...
        /// void OnColor(Dictionary<string, object> data) {
        ///   Debug.Log("received msg with color: " + data["color"]);
        /// }
        /// ]]>
        /// </code>
        /// or
        /// <code>
        /// <![CDATA[
        /// private class MessageColor {
        ///     public string color = "";    // in CSS format rgb(r,g,b)
        /// };
        /// ...
        /// gameServer.RegisterCmdHandler("color", OnColor);
        /// ...
        /// void OnColor(Dictionary<string, object> data) {
        ///   Deserializer d = new Deserializer();
        ///   MessageColor msg = d.Deserialize<MessageColor>(data);
        ///   Debug.Log("received msg with color: " + msg.color);
        /// }
        /// ]]>
        /// </code>
        /// </example>
        /// <param name="name">command to call callback for</param>
        /// <param name="callback">Typed callback</param>
        public void RegisterCmdHandler(string name, UntypedCmdEventHandler callback)
        {
            UntypedCmdConverter converter = new UntypedCmdConverter(callback);

            m_handlers[name] = converter.Callback;
        }