tanghai 13 лет назад
Родитель
Сommit
639ce16359

+ 7 - 0
CSharp/App/BossClient/BossClient.csproj

@@ -32,6 +32,10 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Reference Include="Ionic.Zip, Version=1.9.1.8, Culture=neutral, PublicKeyToken=edbe51ad942a3f5c, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="System.Numerics" />
@@ -63,6 +67,9 @@
       <Name>Log</Name>
     </ProjectReference>
   </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(SolutionDir)\.nuget\nuget.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 12 - 8
CSharp/App/BossClient/ENetChannel.cs

@@ -5,6 +5,7 @@ using System.Text;
 using System.Threading.Tasks;
 using ENet;
 using Helper;
+using Ionic.Zlib;
 using Log;
 
 namespace BossClient
@@ -42,16 +43,19 @@ namespace BossClient
 				byte[] bytes = packet.Bytes;
 				const int opcodeSize = sizeof(ushort);
 				ushort opcode = BitConverter.ToUInt16(bytes, 0);
-				const int flagSize = sizeof (ushort);
-				ushort flag = BitConverter.ToUInt16(bytes, opcodeSize);
-				if (flag != 0)
+				byte flag = bytes[0];
+				if (flag == 0)
 				{
-					Logger.Debug("packet zip");
-					throw new BossException("packet zip!");
+					var messageBytes = new byte[packet.Length - opcodeSize - 1];
+					Array.Copy(bytes, opcodeSize + 1, messageBytes, 0, messageBytes.Length);
+					return Tuple.Create(opcode, messageBytes);
+				}
+				else
+				{
+					var messageBytes = new byte[packet.Length - opcodeSize - 5];
+					Array.Copy(bytes, opcodeSize + 5, messageBytes, 0, messageBytes.Length);
+					return Tuple.Create(opcode, ZlibStream.UncompressBuffer(messageBytes));
 				}
-				var messageBytes = new byte[packet.Length - opcodeSize - flagSize];
-				Array.Copy(bytes, opcodeSize + flagSize, messageBytes, 0, messageBytes.Length);
-				return Tuple.Create(opcode, messageBytes);
 			}
 		}
 	}

+ 8 - 0
CSharp/App/BossClient/Messages.cs

@@ -28,6 +28,7 @@ namespace BossClient
 		public const ushort SMSG_SERVERTIME = 510;
 
 		public const ushort SMSG_BOSS_SERVERSINFO = 22000;
+		public const ushort SMSG_BOSS_COMMAND_RESPONSE = 22001;
 	}
 
 	public static class ErrorCode
@@ -242,4 +243,11 @@ namespace BossClient
 		[DataMember(Order = 1, IsRequired = true)]
 		public List<string> Name { get; set; }
 	}
+
+	[DataContract]
+	public class SMSG_Boss_Command_Response
+	{
+		[DataMember(Order = 1, IsRequired = true)]
+		public uint ErrorCode { get; set; }
+	}
 }

+ 4 - 0
CSharp/App/BossClient/Packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="DotNetZip" version="1.9.1.8" targetFramework="net45" />
+</packages>

+ 41 - 25
CSharp/App/Modules/Robot/RobotView.xaml

@@ -25,31 +25,47 @@
 			</ListBox>
 			<Grid>
 				<Canvas>
-					<ComboBox x:Name="cbFindType" SelectedIndex="{Binding FindTypeIndex}" Canvas.Left="42" Canvas.Top="19">
-						<ComboBoxItem Content="帐号"/>
-						<ComboBoxItem Content="名字"/>
-						<ComboBoxItem Content="GUID"/>
-					</ComboBox>
-					<TextBox Width="120" Text="{Binding FindType}" Canvas.Left="103" Canvas.Top="20" />
-					<Button Name="btnFind" Content="查询" Click="btnFind_Click" Canvas.Left="239" Canvas.Top="20" ></Button>
-					<GroupBox Header="角色信息" Canvas.Left="42" Canvas.Top="57" Height="163" Width="243">
-						<Grid Margin="0,10,0,0">
-							<Grid.RowDefinitions>
-								<RowDefinition></RowDefinition>
-								<RowDefinition></RowDefinition>
-								<RowDefinition></RowDefinition>
-							</Grid.RowDefinitions>
-							<Grid.ColumnDefinitions>
-								<ColumnDefinition Width="67*"></ColumnDefinition>
-								<ColumnDefinition Width="190*"></ColumnDefinition>
-							</Grid.ColumnDefinitions>
-							<Label Content="帐号:" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Height="26" Width="36" />
-							<TextBox Text="{Binding Account}"  Grid.Row="0" Grid.Column="1" Margin="0,8" />
-							<Label Content="名字:" Grid.Row="1" Grid.Column="0" Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Height="23" Width="36" />
-							<TextBox Text="{Binding Name}" Grid.Row="1" Grid.Column="1" Margin="0,8" />
-							<Label Content="GUID:" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Height="26" Width="44" />
-							<TextBox Text="{Binding Guid}" Grid.Row="2" Grid.Column="1" Margin="0,8"/>
-						</Grid>
+					<GroupBox Header="角色信息" Canvas.Left="40" Canvas.Top="22" Height="518" Width="660">
+						<Canvas>
+							<StackPanel Orientation="Horizontal" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Canvas.Left="32" Canvas.Top="23">
+								<ComboBox x:Name="cbFindType" SelectedIndex="{Binding FindTypeIndex}">
+									<ComboBoxItem Content="帐号"/>
+									<ComboBoxItem Content="名字"/>
+									<ComboBoxItem Content="GUID"/>
+								</ComboBox>
+								<TextBox Width="178" Text="{Binding FindType}"/>
+								<Button Name="btnFind" Content="查询" Click="btnFind_Click"></Button>
+							</StackPanel>
+							<Label Content="帐号:" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="52" />
+							<TextBox Text="{Binding Account}"  Grid.Row="1" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="53" Width="146"/>
+							<Label Content="名字:" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="83" />
+							<TextBox Text="{Binding Name}" Grid.Row="2" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="84" Width="146"/>
+							<Label Content="GUID:" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Center" Canvas.Left="32" Canvas.Top="114" />
+							<TextBox Text="{Binding Guid}" Grid.Row="3" Grid.Column="1" IsReadOnly="True" Height="25" Canvas.Left="88" Canvas.Top="114" Width="146"/>
+							<TabControl Height="315" Canvas.Top="180" Width="648">
+								<TabItem Header="信息">
+									<Grid/>
+								</TabItem>
+								<TabItem Header="包裹">
+									<Grid/>
+								</TabItem>
+								<TabItem Header="BUFF">
+									<Grid/>
+								</TabItem>
+								<TabItem Header="装备">
+									<Canvas>
+
+									</Canvas>
+								</TabItem>
+								<TabItem Header="GM">
+									<Canvas>
+										<Button Name="btnForbiddenBuy" Content="禁止交易" Canvas.Left="11" Canvas.Top="10" Width="75" Click="btnForbiddenBuy_Click"/>
+										<Button Content="允许交易" Canvas.Left="11" Canvas.Top="38" Width="75"/>
+									</Canvas>
+								</TabItem>
+							</TabControl>
+							<Label Name="lblErrorInfo" Content="{Binding ErrorInfo}" Canvas.Left="281" Canvas.Top="114" Width="201" Height="25"/>
+						</Canvas>
 					</GroupBox>
 				</Canvas>
 			</Grid>

+ 5 - 0
CSharp/App/Modules/Robot/RobotView.xaml.cs

@@ -46,5 +46,10 @@ namespace Modules.Robot
 		private void menuLogin_Click(object sender, RoutedEventArgs e)
 		{
 		}
+
+		private void btnForbiddenBuy_Click(object sender, RoutedEventArgs e)
+		{
+			this.ViewModel.ForbiddenBuy();
+		}
 	}
 }

+ 35 - 2
CSharp/App/Modules/Robot/RobotViewModel.cs

@@ -34,6 +34,8 @@ namespace Modules.Robot
 		public readonly Dictionary<ushort, Action<byte[]>> messageHandlers =
 			new Dictionary<ushort, Action<byte[]>>();
 
+		private string errorInfo = "";
+
 		public IMessageChannel IMessageChannel { get; set; }
 
 		public int FindTypeIndex
@@ -146,11 +148,31 @@ namespace Modules.Robot
 			}
 		}
 
+		public string ErrorInfo
+		{
+			get
+			{
+				return this.errorInfo;
+			}
+			set
+			{
+				if (this.errorInfo == value)
+				{
+					return;
+				}
+				this.errorInfo = value;
+				this.RaisePropertyChanged("ErrorInfo");
+			}
+		}
+
 		[ImportingConstructor]
 		public RobotViewModel(IEventAggregator eventAggregator)
 		{
 			this.messageHandlers.Add(
-				MessageOpcode.SMSG_BOSS_SERVERSINFO, Handle_SMSG_Boss_ServersInfo);
+				MessageOpcode.SMSG_BOSS_SERVERSINFO, this.Handle_SMSG_Boss_ServersInfo);
+			this.messageHandlers.Add(
+				MessageOpcode.SMSG_BOSS_COMMAND_RESPONSE, this.Handle_SMSG_Boss_Command_Response);
+
 			eventAggregator.GetEvent<LoginOKEvent>().Subscribe(this.OnLoginOK);
 		}
 
@@ -211,6 +233,12 @@ namespace Modules.Robot
 			this.SendCommand("servers");
 		}
 
+		public void Handle_SMSG_Boss_Command_Response(byte[] message)
+		{
+			var smsgBossCommandResponse = ProtobufHelper.FromBytes<SMSG_Boss_Command_Response>(message);
+			this.ErrorInfo = smsgBossCommandResponse.ErrorCode.ToString();
+		}
+
 		public void Handle_SMSG_Boss_ServersInfo(byte[] message)
 		{
 			var smsgBossServersInfo = ProtobufHelper.FromBytes<SMSG_Boss_ServersInfo>(message);
@@ -260,11 +288,16 @@ namespace Modules.Robot
 					Logger.Debug("not find charactor info!");
 					return;
 				}
-
+				
 				this.Account = result.account;
 				this.Name = result.character_name;
 				this.Guid = result.character_guid.ToString(CultureInfo.InvariantCulture);
 			}
 		}
+
+		public void ForbiddenBuy()
+		{
+			this.SendCommand(string.Format("{0} 600", guid));
+		}
 	}
 }