WriteDataObject() public method

public WriteDataObject ( ByteArray data ) : void
data ByteArray
return void
Beispiel #1
0
        public void OnSIDComplete(SID sid)
        {
            try
            {
                if (sid.Length == POLICY_REQUEST.Length && sid.ReadUTF() == POLICY_REQUEST)
                {
                    sid.Send(POLICY_FILE);
                }
                else
                {
                    Session caller = null;

                    string callerType = sid.Data.ReadUTF8();

                    if (sid.ID != null)
                    {
                        if (Caller.ContainsKey(callerType))
                        {
                            ConstructorInfo constructorInfo = Caller[callerType].GetConstructor(new Type[1] { typeof(SID) });
                            caller = (Session)constructorInfo.Invoke(new object[1] { sid });
                        }

                        if (OnCaller != null)
                            OnCaller(caller);
                    }
                    else if (callerType == SessionID.Type)
                    {
                        caller = sid.ID = new SessionID(sid);

                        if (OnLogin != null)
                            OnLogin(sid.ID);
                    }
                    else
                    {
                        Console.WriteLine("Caller not found \"" + callerType + "\"");
                    }

                    if (caller != null)
                    {
                        ByteArray data = new ByteArray();
                        data.WriteDataObject(caller.Run());

                        sid.Send(data);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }