Exemple #1
0
		private static void PacketDecode(Socket socket, SocketToken Token, bool IsDecode) {
                        int iCheck = 0;
                        PacketBuffer cPacket = Token.ReceiveBuffer;
                        cPacket.Position = -1;
                        while (++cPacket.Position < cPacket.Length) {
                                        iCheck = VerifyPacket(cPacket);
                                        switch (iCheck) {
                                                case -1: //未知封包
							if (Token.IsStart) {
								if (cPacket[0] == 0x0b) {
									if (McpDecoder.McpDecode(socket, Token)) {
										continue;
									}
								}
								Token.IsStart = false;
							}
							Token.AddTemp();
                                                        break;
                                                case 0:  //完整封包
                                                        int iSize = cPacket[3] + 4;
                                                        Token.SetPackage(iSize);
                                                        DecodeFinance(socket, Token.StockEvent, IsDecode);
                                                        cPacket.Position += (iSize - 1);
							Token.IsStart = true;
                                                        break;
                                                case 1:  //末端斷包
                                                        while (++cPacket.Position < cPacket.Length)
                                                                Token.AddTemp();
                                                        break;
                                        }
                                
                        }
                }
Exemple #2
0
                private static void PacketDecode(Socket socket, SocketToken Token) {
                        PacketBuffer cPacket = Token.ReceiveBuffer;

                        cPacket.Position = -1;
                        while (++cPacket.Position < cPacket.Length) {
                                //判斷是否是MCP標頭格式
                                if (cPacket[0] == 0x0b) {
					if (logger.IsDebugEnabled) logger.Debug("[McpDecoder.PacketDecode] Start decode MCP packet...");
                                        if (McpDecode(socket, Token)) {
						continue;
                                        }
					if (logger.IsDebugEnabled) logger.Debug("[McpDecoder.PacketDecode] End decode MCP packet...");
                                }
			
				Token.AddTemp();
			}
                }