Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Renaming that weird OneNetwork to BrightNetwork since I just copy pas…
…ted PROShine's BrightNetwork xD
  • Loading branch information
IamSanjid committed Nov 30, 2018
1 parent 8965ba7 commit 5faf777
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 60 deletions.
8 changes: 4 additions & 4 deletions OneNetwork/ANetwork.cs → BrightNetwork/BrightClient.cs
Expand Up @@ -2,9 +2,9 @@
using System.Net;
using System.Net.Sockets;

namespace OneNetwork
namespace BrightNetwork
{
public class ANetwork
public class BrightClient
{
public event Action Connected;
public event Action<Exception> Disconnected;
Expand All @@ -22,12 +22,12 @@ public IPAddress RemoteIPAddress
private bool _isClosed;
private byte[] _receiveBuffer;

public ANetwork()
public BrightClient()
{
_receiveBuffer = new byte[4096];
}

public ANetwork(Socket socket)
public BrightClient(Socket socket)
{
_receiveBuffer = new byte[4096];
Initialize(socket);
Expand Down
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{BD428769-4F66-4D9D-AB36-2D0AA9EFBFD5}</ProjectGuid>
<ProjectGuid>{F6F45690-9361-4DA4-8A8A-18D782E29752}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>OneNetwork</RootNamespace>
<AssemblyName>OneNetwork</AssemblyName>
<RootNamespace>BrightNetwork</RootNamespace>
<AssemblyName>BrightNetwork</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
Expand All @@ -22,7 +22,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
Expand All @@ -40,11 +40,17 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ANetwork.cs" />
<Compile Include="OneConnection.cs" />
<Compile Include="BrightClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SimpleTextClient.cs" />
<Compile Include="SocksConnection.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Expand Up @@ -2,34 +2,34 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("OneNetwork")]
[assembly: AssemblyTitle("BrightNetwork")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OneNetwork")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyProduct("BrightNetwork")]
[assembly: AssemblyCopyright("Copyright © Silv3r, 2016-2032")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("bd428769-4f66-4d9d-ab36-2d0aa9efbfd5")]
[assembly: Guid("f6f45690-9361-4da4-8a8a-18d782e29752")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
Expand Down
Expand Up @@ -4,18 +4,18 @@
using System.Net.Sockets;
using System.Text;

namespace OneNetwork
namespace BrightNetwork
{
public class OneConnection
public class SimpleTextClient
{
public event Action Connected;
public event Action<Exception> Disconnected;
public event Action<string> PacketReceived;

protected string PacketDelimiter = "\r\n";
protected string PacketDelimiter = "\n";
protected Encoding TextEncoding = Encoding.UTF8;

private readonly ANetwork _client;
private readonly BrightClient _client;

private string _receiveBuffer = string.Empty;
private Queue<string> _pendingPackets = new Queue<string>();
Expand All @@ -34,7 +34,7 @@ public IPAddress RemoteIPAddress
get { return _client.RemoteIPAddress; }
}

public OneConnection(ANetwork client)
public SimpleTextClient(BrightClient client)
{
_client = client;

Expand Down Expand Up @@ -150,7 +150,7 @@ private void ExtractPackets()
}
while (hasExtracted);
}

private bool ExtractPendingPacket()
{
int pos = _receiveBuffer.IndexOf(PacketDelimiter);
Expand Down
Expand Up @@ -4,7 +4,7 @@
using System.Text;
using System.Threading.Tasks;

namespace OneNetwork
namespace BrightNetwork
{
public static class SocksConnection
{
Expand Down
4 changes: 0 additions & 4 deletions Poke1Bot/Poke1Bot.csproj
Expand Up @@ -75,10 +75,6 @@
<Compile Include="Utils\TaskUtils.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OneNetwork\OneNetwork.csproj">
<Project>{bd428769-4f66-4d9d-ab36-2d0aa9efbfd5}</Project>
<Name>OneNetwork</Name>
</ProjectReference>
<ProjectReference Include="..\Poke1Protocol\Poke1Protocol.csproj">
<Project>{856b3d4c-9717-4828-a46c-0d9c4454c28e}</Project>
<Name>Poke1Protocol</Name>
Expand Down
20 changes: 12 additions & 8 deletions Poke1Protocol/GameClient.cs
Expand Up @@ -12,11 +12,11 @@

namespace Poke1Protocol
{
public class GameClient
public class GameClient : IDisposable
{
#region From PSXAPI.DLL
private TimeSpan pingUpdateTime = TimeSpan.FromSeconds(5.0);
private readonly Timer timer;
private Timer timer { get; set; }
private DateTime lastPingResponseUtc;
private bool receivedPing;
private volatile int ping;
Expand Down Expand Up @@ -825,16 +825,11 @@ private void OnConnectionClosed(Exception ex)
#endif
ConnectionClosed?.Invoke(ex);
}
if (!disposedValue)
{
timer.Dispose();
disposedValue = true;
}
}

private void Timer(object obj)
{
if (IsConnected && receivedPing)
if (IsConnected && receivedPing && !disposedValue)
{
receivedPing = false;
SendProto(new PSXAPI.Request.Ping
Expand Down Expand Up @@ -3361,6 +3356,15 @@ public static string GetStatus(string status)
}
return status;
}

public void Dispose()
{
if (!disposedValue)
{
timer.Dispose();
disposedValue = true;
}
}
}

public static class StringExtention
Expand Down
10 changes: 7 additions & 3 deletions Poke1Protocol/GameConnection.cs
@@ -1,11 +1,12 @@
using OneNetwork;
using BrightNetwork;
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace Poke1Protocol
{
public class GameConnection : OneConnection
public class GameConnection : SimpleTextClient
{
// game server port = 2012, map server port = 2015, map host = maps.poke.one, game host = game.poke.one
private const int _serverPort = 2012;
Expand All @@ -17,9 +18,12 @@ public class GameConnection : OneConnection
private string _socksUser;
private string _socksPass;
private string _host => new Random().Next(1, 2) == 1 ? "95.183.48.120" : "95.183.48.68";

public GameConnection()
: base(new ANetwork())
: base(new BrightClient())
{
PacketDelimiter = "\r\n";
TextEncoding = Encoding.UTF8;
}

public GameConnection(int socksVersion, string socksHost, int socksPort, string socksUser, string socksPass)
Expand Down
9 changes: 6 additions & 3 deletions Poke1Protocol/MapConnection.cs
@@ -1,11 +1,12 @@
using OneNetwork;
using BrightNetwork;
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace Poke1Protocol
{
public class MapConnection : OneConnection
public class MapConnection : SimpleTextClient
{
private const string ServerAddress = "95.183.55.67";
private const int ServerPort = 2015;
Expand All @@ -18,8 +19,10 @@ public class MapConnection : OneConnection
private string _socksPass;

public MapConnection()
: base(new ANetwork())
: base(new BrightClient())
{
PacketDelimiter = "\r\n";
TextEncoding = Encoding.UTF8;
}

public MapConnection(int socksVersion, string socksHost, int socksPort, string socksUser, string socksPass)
Expand Down
13 changes: 6 additions & 7 deletions Poke1Protocol/Poke1Protocol.csproj
Expand Up @@ -93,12 +93,6 @@
<Compile Include="SwitchedPokemon.cs" />
<Compile Include="TypesManager.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OneNetwork\OneNetwork.csproj">
<Project>{bd428769-4f66-4d9d-ab36-2d0aa9efbfd5}</Project>
<Name>OneNetwork</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>PublicResXFileCodeGenerator</Generator>
Expand All @@ -111,6 +105,11 @@
<None Include="Resources\moves.json" />
<None Include="Resources\pokemons.json" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\BrightNetwork\BrightNetwork.csproj">
<Project>{f6f45690-9361-4da4-8a8a-18d782e29752}</Project>
<Name>BrightNetwork</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
12 changes: 6 additions & 6 deletions pokeone+.sln
Expand Up @@ -7,10 +7,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pokeone+", "pokeone+\pokeon
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Poke1Protocol", "Poke1Protocol\Poke1Protocol.csproj", "{856B3D4C-9717-4828-A46C-0D9C4454C28E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OneNetwork", "OneNetwork\OneNetwork.csproj", "{BD428769-4F66-4D9D-AB36-2D0AA9EFBFD5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Poke1Bot", "Poke1Bot\Poke1Bot.csproj", "{DE6DD8AF-847D-4A7C-A9F7-1415DDF8E548}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BrightNetwork", "BrightNetwork\BrightNetwork.csproj", "{F6F45690-9361-4DA4-8A8A-18D782E29752}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -25,14 +25,14 @@ Global
{856B3D4C-9717-4828-A46C-0D9C4454C28E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{856B3D4C-9717-4828-A46C-0D9C4454C28E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{856B3D4C-9717-4828-A46C-0D9C4454C28E}.Release|Any CPU.Build.0 = Release|Any CPU
{BD428769-4F66-4D9D-AB36-2D0AA9EFBFD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD428769-4F66-4D9D-AB36-2D0AA9EFBFD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD428769-4F66-4D9D-AB36-2D0AA9EFBFD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD428769-4F66-4D9D-AB36-2D0AA9EFBFD5}.Release|Any CPU.Build.0 = Release|Any CPU
{DE6DD8AF-847D-4A7C-A9F7-1415DDF8E548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE6DD8AF-847D-4A7C-A9F7-1415DDF8E548}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE6DD8AF-847D-4A7C-A9F7-1415DDF8E548}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE6DD8AF-847D-4A7C-A9F7-1415DDF8E548}.Release|Any CPU.Build.0 = Release|Any CPU
{F6F45690-9361-4DA4-8A8A-18D782E29752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6F45690-9361-4DA4-8A8A-18D782E29752}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6F45690-9361-4DA4-8A8A-18D782E29752}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F6F45690-9361-4DA4-8A8A-18D782E29752}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion pokeone+/Views/MainWindow.xaml
Expand Up @@ -405,7 +405,7 @@
<MenuItem Style="{StaticResource NoBorderMenu}" BorderThickness="0" Header="_Help">
<MenuItem Foreground="#F1F1F1" BorderThickness="0" BorderBrush="{x:Null}" Click="SourceCode_View_Click" Header="_Source Code (GitHub)"/>
<MenuItem Foreground="#F1F1F1" BorderThickness="0" BorderBrush="{x:Null}" Click="LuaApi_View_Click" Header="_Lua Api(s)"/>
<MenuItem Foreground="#F1F1F1" BorderThickness="0" BorderBrush="{x:Null}" Click="SourceCode_View_Click" Header="_Donate (PayPal)"/>
<MenuItem Foreground="#F1F1F1" BorderThickness="0" BorderBrush="{x:Null}" Click="Donate_Click" Header="_Donate (PayPal)"/>
<MenuItem Foreground="#F1F1F1" BorderThickness="0" BorderBrush="{x:Null}" Click="About_Click" Header="_About"/>
</MenuItem>
</Menu>
Expand Down

0 comments on commit 5faf777

Please sign in to comment.