Exemple #1
0
        void OnRelayConnectedProc(byte[] data)
        {
            ConnectorResult result = convertConnectorResult(data);

            ADebug.Log("c#:OnRelayConnectedProc: " + result);

            if (result == ConnectorErrorCode.Success)
            {
                Connected = true;
            }
            else
            {
                Connected = false;
            }

            if (RelayConnectEvent != null)
            {
                try
                {
                    RelayConnectEvent(result);
                }
                catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
            else
            {
                ADebug.Log("OnRelayConnectedProc RelayConnectEvent is null");
            }
        }
Exemple #2
0
 public override void PerformVoidMethodWithId(int methodId)
 {
     ADebug.Log("PerformVoidMethodWithId");
     if (methodId == 1001)
     {
         if (RecvedDataEvent != null)
         {
             try
             {
                 RecvedDataEvent();
             } catch (Exception ex)
             {
                 ADebug.LogException(ex);
             }
         }
     }
     else if (methodId == 1002)
     {
         if (RecvedUDPDataEvent != null)
         {
             try
             {
                 RecvedUDPDataEvent();
             } catch (Exception ex)
             {
                 ADebug.LogException(ex);
             }
         }
     }
 }
Exemple #3
0
        void OnStateChangedProc(int state, byte[] resultdata)
        {
            ConnectorResult result = convertConnectorResult(resultdata);
            ConnectorState  s      = (ConnectorState)state;

            ADebug.Log("OnStateChangedProc state: " + s + " " + result.ToString());
            if (s == ConnectorState.Reconnected && result.IsSuccess())
            {
                Connected = true;
            }
            else
            {
                Connected = false;
            }

            if (StateChangedEvent != null)
            {
                try
                {
                    StateChangedEvent(s, result);
                } catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
        }
Exemple #4
0
        void OnRouteChangedProc(string msg)
        {
            UInt64 serverId = UInt64.Parse(msg);

            ADebug.Log("OnStateChangedProc msg: " + msg + ", serverId:" + serverId);
            if (RouteChangedEvent != null)
            {
                try
                {
                    RouteChangedEvent(serverId);
                } catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
        }
Exemple #5
0
        public bool Encode(out byte[] buffer)
        {
            try
            {
                ApolloBufferWriter writer = new ApolloBufferWriter();
                BeforeEncode(writer);
                WriteTo(writer);

                buffer = writer.GetBufferData();
                return(true);
            } catch (Exception ex)
            {
                buffer = null;
                ADebug.LogException(ex);
                return(false);
            }
        }
Exemple #6
0
 public bool Decode(ApolloBufferReader reader)
 {
     if (reader != null)
     {
         try
         {
             BeforeDecode(reader);
             ReadFrom(reader);
             return(true);
         }
         catch (Exception ex)
         {
             ADebug.LogException(ex);
             return(false);
         }
     }
     return(false);
 }
Exemple #7
0
        public bool Encode(ApolloBufferWriter writer)
        {
            if (writer == null)
            {
                return(false);
            }
            try
            {
                BeforeEncode(writer);
                WriteTo(writer);

                return(true);
            } catch (Exception ex)
            {
                ADebug.LogException(ex);
                return(false);
            }
        }
Exemple #8
0
 public bool Decode(byte[] data)
 {
     if (data != null)
     {
         try
         {
             ApolloBufferReader reader = new ApolloBufferReader(data);
             BeforeDecode(reader);
             ReadFrom(reader);
             return(true);
         }
         catch (Exception ex)
         {
             ADebug.LogException(ex);
             return(false);
         }
     }
     return(false);
 }
Exemple #9
0
        void OnDisconnectProc(byte[] data)
        {
            ConnectorResult result = convertConnectorResult(data);

            ADebug.Log("c#:OnDisconnectProc: " + result);
            if (result.IsSuccess())
            {
                Connected = false;
            }

            if (DisconnectEvent != null)
            {
                try
                {
                    DisconnectEvent(result);
                } catch (Exception ex)
                {
                    ADebug.LogException(ex);
                }
            }
        }