コード例 #1
0
ファイル: CoflnetSocket.cs プロジェクト: Coflnet/cloud
 protected override void OnClose(CloseEventArgs e)
 {
     Connections.Remove(User.Id);
     Connections.Remove(Device.Id);
     AuthenticatedIds.Clear();
     base.OnClose(e);
 }
コード例 #2
0
ファイル: CoflnetSocket.cs プロジェクト: Coflnet/cloud
    protected override void OnMessage(MessageEventArgs e)
    {
        // try to parse and execute the command sent
        try
        {
            ServerCommandData commandData = Encoder.Deserialize(e);
            // if connection information is needed
            commandData.Connection = this;


            if (commandData.Recipient.ServerId == 0)
            {
                throw new CoflnetException("unknown_server", "this server is unknown (There is no server with the id 0)");
            }


            // prevent id spoofing
            if (commandData.SenderId != new EntityId() && !AuthenticatedIds.Contains(commandData.SenderId))
            {
                throw new NotAuthenticatedAsException(commandData.SenderId);
            }


            EntityManager.Instance.ExecuteForReference(commandData);
            //	var controllerForObject = ReferenceManager.Instance.GetResource(commandData.rId)
            //					.GetCommandController();

            //	controllerForObject.ExecuteCommand(commandData);
        }
        catch (CoflnetException ex)
        {
            Encoder.Send(new CoflnetExceptionTransmit(ex), this);
            Track.instance.Error(ex.Message, e.Data, ex.StackTrace);
        }

        /*
         * catch (Exception ex)
         * {
         *      Track.instance.Error(ex.Message, e.Data, ex.StackTrace);
         * }*/
        //Logger.Log(ID);
        //Logger.Log("Got some data :)");
    }