Example #1
0
 /// <summary>
 /// 操作数据
 /// </summary>
 /// <param name="parameter">短路径操作参数</param>
 /// <returns>返回参数</returns>
 internal ValueData.Data Operation(ref OperationParameter.ShortPathOperationNode parameter)
 {
     if (CanWrite)
     {
         if (parameter.Buffer != null)
         {
             if (parameter.Identity.Ticks == startTicks)
             {
                 byte[]           packet;
                 Cache.Value.Node node = shortPaths[parameter.Identity.Index].Get(parameter.Identity.Identity, out packet);
                 if (packet.Length == parameter.Identity.PacketSize)
                 {
                     if (node.IsNode)
                     {
                         byte[] bufferData = parameter.Buffer.Array.Array;
                         System.Buffer.BlockCopy(packet, 0, bufferData, parameter.Buffer.Array.Start + OperationParameter.Serializer.HeaderSize, parameter.Identity.PacketSize);
                         fixed(byte *bufferFixed = bufferData)
                         {
                             OperationParameter.NodeParser parser = new OperationParameter.NodeParser(this, parameter.Buffer, bufferFixed);
                             parser.Read += parameter.Identity.PacketSize;
                             node.Operation(ref parser);
                             if (parser.IsOperation)
                             {
                                 onOperation(parameter.Buffer);
                             }
                             else
                             {
                                 parameter.Buffer.FreeReference();
                             }
                             return(parser.ReturnParameter);
                         }
                     }
                     return(new ValueData.Data(ReturnType.NotFoundShortPathNode));
                 }
             }
             return(new ValueData.Data(ReturnType.NotFoundShortPath));
         }
         return(new ValueData.Data(ReturnType.ServerDeSerializeError));
     }
     return(new ValueData.Data(ReturnType.CanNotWrite));
 }
Example #2
0
 internal void OperationAsynchronousStream(OperationParameter.ShortPathOperationNode parameter, Func <AutoCSer.Net.TcpServer.ReturnValue <ReturnParameter>, bool> onOperation)
 {
     TcpServer.CallQueue.Add(new ServerCall.ShortPathOperationAsynchronous(Cache, ref parameter, onOperation));
 }
Example #3
0
 internal ReturnParameter OperationStream(OperationParameter.ShortPathOperationNode parameter)
 {
     ValueData.Data returnValue = Cache.Operation(ref parameter);
     returnValue.IsReturnDeSerializeStream = true;
     return(new ReturnParameter(ref returnValue));
 }
Example #4
0
 internal ReturnParameter Operation(OperationParameter.ShortPathOperationNode parameter)
 {
     return(new ReturnParameter(Cache.Operation(ref parameter)));
 }
Example #5
0
        /// <summary>
        /// 操作数据
        /// </summary>
        /// <param name="parameter">短路径操作参数</param>
        /// <param name="onOperation"></param>
        internal void Operation(ref OperationParameter.ShortPathOperationNode parameter, Func <AutoCSer.Net.TcpServer.ReturnValue <ReturnParameter>, bool> onOperation)
        {
            ReturnType returnType = ReturnType.CanNotWrite;

            try
            {
                if (CanWrite)
                {
                    if (parameter.Buffer != null)
                    {
                        returnType = ReturnType.NotFoundShortPath;
                        if (parameter.Identity.Ticks == startTicks)
                        {
                            byte[]           packet;
                            Cache.Value.Node node = shortPaths[parameter.Identity.Index].Get(parameter.Identity.Identity, out packet);
                            if (packet.Length == parameter.Identity.PacketSize)
                            {
                                if (node.IsNode)
                                {
                                    returnType = ReturnType.Unknown;
                                    byte[] bufferData = parameter.Buffer.Array.Array;
                                    System.Buffer.BlockCopy(packet, 0, bufferData, parameter.Buffer.Array.Start + OperationParameter.Serializer.HeaderSize, parameter.Identity.PacketSize);
                                    fixed(byte *bufferFixed = bufferData)
                                    {
                                        OperationParameter.NodeParser parser = new OperationParameter.NodeParser(this, parameter.Buffer, bufferFixed);
                                        parser.Read    += parameter.Identity.PacketSize;
                                        parser.OnReturn = onOperation;
                                        try
                                        {
                                            node.Operation(ref parser);
                                        }
                                        finally
                                        {
                                            if (parser.OnReturn == null)
                                            {
                                                returnType = ReturnType.Success;
                                            }
                                        }
                                        if (parser.IsOperation)
                                        {
                                            this.onOperation(parameter.Buffer);
                                        }
                                        else
                                        {
                                            parameter.Buffer.FreeReference();
                                        }
                                        return;
                                    }
                                }
                                else
                                {
                                    returnType = ReturnType.NotFoundShortPathNode;
                                }
                            }
                        }
                    }
                    else
                    {
                        returnType = ReturnType.ServerDeSerializeError;
                    }
                }
                parameter.Buffer.FreeReference();
            }
            finally
            {
                if (returnType != ReturnType.Success)
                {
                    onOperation(new ReturnParameter(returnType));
                }
            }
        }
Example #6
0
 internal void OperationAsynchronousStream(OperationParameter.ShortPathOperationNode parameter, AutoCSer.Net.TcpServer.ServerCallback <ReturnParameter> onOperation)
 {
     Cache.Operation(ref parameter, onOperation);
 }
Example #7
0
 internal void OperationAsynchronous(OperationParameter.ShortPathOperationNode parameter, AutoCSer.Net.TcpServer.ServerCallback <ReturnParameter> onOperation)
 {
     Cache.Operation(ref parameter, onOperation);
     //TcpServer.CallQueue.Add(new ServerCall.ShortPathOperationAsynchronous(Cache, ref parameter, onOperation));
 }