예제 #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");
            }
        }
예제 #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);
             }
         }
     }
 }
예제 #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);
                }
            }
        }
예제 #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);
                }
            }
        }
예제 #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);
            }
        }
예제 #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);
 }
예제 #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);
            }
        }
예제 #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);
 }
예제 #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);
                }
            }
        }