Example #1
0
        private void PeerManager_msgReceived(object sender, TransportLayer.EventArgs.MsgReceivedEventArgs e)
        {
            byte[]  msg = e.Message;
            BObject obj = new BObject(msg, serializer);

            //generate metadata
            Metadata metadata = obj.GetMetadata();

            metadata.BindType = e.BindingType;
            ObjReceived?.Invoke(this, new ObjReceivedEventArgs(obj, metadata));
        }
Example #2
0
        private async void ObjManager_objReceived(object sender, ObjReceivedEventArgs e)
        {
            BObject  bObj     = e.Obj;
            Metadata metadata = bObj.GetMetadata();

            ObjReceived?.Invoke(this, e);

            string objType = bObj.GetType();

            switch (objType)
            {
            case "FilePartObj":
                FilePartObj filePart = e.Obj.GetObject <FilePartObj>();
                await ProcessFilePart(filePart, metadata);

                break;

            /*
             * case "FileAck":
             * FileAck ackMsg = e.Obj.GetObject<FileAck>();
             * await ProcessAckMessage(ackMsg, metadata);
             * break;
             */
            case "FileReqMeta":
                FileReqMeta fileRequestMetadata = e.Obj.GetObject <FileReqMeta>();
                await ProcessIncomingFilesRequest(fileRequestMetadata, metadata);

                break;

            case "ReqAck":
                ReqAck fileReqAck = e.Obj.GetObject <ReqAck>();
                await ProcessFileReqAck(fileReqAck, metadata);

                break;

            default:
                break;
            }
        }