@@ -0,0 +1,22 @@ | |||
# Auto detect text files and perform LF normalization | |||
* text=auto | |||
# Custom for Visual Studio | |||
*.cs diff=csharp | |||
*.sln merge=union | |||
*.csproj merge=union | |||
*.vbproj merge=union | |||
*.fsproj merge=union | |||
*.dbproj merge=union | |||
# Standard to msysgit | |||
*.doc diff=astextplain | |||
*.DOC diff=astextplain | |||
*.docx diff=astextplain | |||
*.DOCX diff=astextplain | |||
*.dot diff=astextplain | |||
*.DOT diff=astextplain | |||
*.pdf diff=astextplain | |||
*.PDF diff=astextplain | |||
*.rtf diff=astextplain | |||
*.RTF diff=astextplain |
@@ -0,0 +1,213 @@ | |||
################# | |||
## Eclipse | |||
################# | |||
*.pydevproject | |||
.project | |||
.metadata | |||
bin/ | |||
tmp/ | |||
*.tmp | |||
*.bak | |||
*.swp | |||
*~.nib | |||
local.properties | |||
.classpath | |||
.settings/ | |||
.loadpath | |||
# External tool builders | |||
.externalToolBuilders/ | |||
# Locally stored "Eclipse launch configurations" | |||
*.launch | |||
# CDT-specific | |||
.cproject | |||
# PDT-specific | |||
.buildpath | |||
################# | |||
## Visual Studio | |||
################# | |||
## Ignore Visual Studio temporary files, build results, and | |||
## files generated by popular Visual Studio add-ons. | |||
# User-specific files | |||
*.suo | |||
*.user | |||
*.sln.docstates | |||
# Build results | |||
[Dd]ebug/ | |||
x64/ | |||
build/ | |||
[Oo]bj/ | |||
# MSTest test Results | |||
[Tt]est[Rr]esult*/ | |||
[Bb]uild[Ll]og.* | |||
*_i.c | |||
*_p.c | |||
*.ilk | |||
*.meta | |||
*.obj | |||
*.pch | |||
*.pdb | |||
*.pgc | |||
*.pgd | |||
*.rsp | |||
*.sbr | |||
*.tlb | |||
*.tli | |||
*.tlh | |||
*.tmp | |||
*.tmp_proj | |||
*.log | |||
*.vspscc | |||
*.vssscc | |||
.builds | |||
*.pidb | |||
*.log | |||
*.scc | |||
# Visual C++ cache files | |||
ipch/ | |||
*.aps | |||
*.ncb | |||
*.opensdf | |||
*.sdf | |||
*.cachefile | |||
# Visual Studio profiler | |||
*.psess | |||
*.vsp | |||
*.vspx | |||
# Guidance Automation Toolkit | |||
*.gpState | |||
# ReSharper is a .NET coding add-in | |||
_ReSharper*/ | |||
*.[Rr]e[Ss]harper | |||
# TeamCity is a build add-in | |||
_TeamCity* | |||
# DotCover is a Code Coverage Tool | |||
*.dotCover | |||
# NCrunch | |||
*.ncrunch* | |||
.*crunch*.local.xml | |||
# Installshield output folder | |||
[Ee]xpress/ | |||
# DocProject is a documentation generator add-in | |||
DocProject/buildhelp/ | |||
DocProject/Help/*.HxT | |||
DocProject/Help/*.HxC | |||
DocProject/Help/*.hhc | |||
DocProject/Help/*.hhk | |||
DocProject/Help/*.hhp | |||
DocProject/Help/Html2 | |||
DocProject/Help/html | |||
# Click-Once directory | |||
publish/ | |||
# Publish Web Output | |||
*.Publish.xml | |||
*.pubxml | |||
# NuGet Packages Directory | |||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line | |||
#packages/ | |||
# Windows Azure Build Output | |||
csx | |||
*.build.csdef | |||
# Windows Store app package directory | |||
AppPackages/ | |||
# Others | |||
sql/ | |||
*.Cache | |||
ClientBin/ | |||
[Ss]tyle[Cc]op.* | |||
~$* | |||
*~ | |||
*.dbmdl | |||
*.[Pp]ublish.xml | |||
*.pfx | |||
*.publishsettings | |||
# RIA/Silverlight projects | |||
Generated_Code/ | |||
# Backup & report files from converting an old project file to a newer | |||
# Visual Studio version. Backup files are not needed, because we have git ;-) | |||
_UpgradeReport_Files/ | |||
Backup*/ | |||
UpgradeLog*.XML | |||
UpgradeLog*.htm | |||
# SQL Server files | |||
App_Data/*.mdf | |||
App_Data/*.ldf | |||
############# | |||
## Windows detritus | |||
############# | |||
# Windows image file caches | |||
Thumbs.db | |||
ehthumbs.db | |||
# Folder config file | |||
Desktop.ini | |||
# Recycle Bin used on file shares | |||
$RECYCLE.BIN/ | |||
# Mac crap | |||
.DS_Store | |||
############# | |||
## Python | |||
############# | |||
*.py[co] | |||
# Packages | |||
*.egg | |||
*.egg-info | |||
dist/ | |||
build/ | |||
eggs/ | |||
parts/ | |||
var/ | |||
sdist/ | |||
develop-eggs/ | |||
.installed.cfg | |||
# Installer logs | |||
pip-log.txt | |||
# Unit test / coverage reports | |||
.coverage | |||
.tox | |||
#Translations | |||
*.mo | |||
#Mr Developer | |||
.mr.developer.cfg |
@@ -0,0 +1,56 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<Project ToolsVersion="12.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>{23E4C371-16E4-4FAC-8B11-44288399BB55}</ProjectGuid> | |||
<OutputType>Library</OutputType> | |||
<AppDesignerFolder>Properties</AppDesignerFolder> | |||
<RootNamespace>Combot</RootNamespace> | |||
<AssemblyName>Combot</AssemblyName> | |||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion> | |||
<FileAlignment>512</FileAlignment> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
<DebugSymbols>true</DebugSymbols> | |||
<DebugType>full</DebugType> | |||
<Optimize>false</Optimize> | |||
<OutputPath>bin\Debug\</OutputPath> | |||
<DefineConstants>DEBUG;TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
<DebugType>pdbonly</DebugType> | |||
<Optimize>true</Optimize> | |||
<OutputPath>bin\Release\</OutputPath> | |||
<DefineConstants>TRACE</DefineConstants> | |||
<ErrorReport>prompt</ErrorReport> | |||
<WarningLevel>4</WarningLevel> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<Reference Include="System" /> | |||
<Reference Include="System.Core" /> | |||
<Reference Include="System.Xml.Linq" /> | |||
<Reference Include="System.Data.DataSetExtensions" /> | |||
<Reference Include="Microsoft.CSharp" /> | |||
<Reference Include="System.Data" /> | |||
<Reference Include="System.Xml" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Compile Include="IRCService.cs" /> | |||
<Compile Include="Interface.cs" /> | |||
<Compile Include="Properties\AssemblyInfo.cs" /> | |||
<Compile Include="TCP\TCPInterface.cs" /> | |||
<Compile Include="TCP\TCPTypes.cs" /> | |||
</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> |
@@ -0,0 +1,22 @@ | |||
| |||
Microsoft Visual Studio Solution File, Format Version 12.00 | |||
# Visual Studio 2013 | |||
VisualStudioVersion = 12.0.31101.0 | |||
MinimumVisualStudioVersion = 10.0.40219.1 | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Combot", "Combot.csproj", "{23E4C371-16E4-4FAC-8B11-44288399BB55}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|Any CPU = Debug|Any CPU | |||
Release|Any CPU = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||
{23E4C371-16E4-4FAC-8B11-44288399BB55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{23E4C371-16E4-4FAC-8B11-44288399BB55}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{23E4C371-16E4-4FAC-8B11-44288399BB55}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{23E4C371-16E4-4FAC-8B11-44288399BB55}.Release|Any CPU.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
EndGlobalSection | |||
EndGlobal |
@@ -0,0 +1,20 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Combot | |||
{ | |||
internal class IRCService | |||
{ | |||
private TCPInterface _tcp; | |||
internal IRCService() | |||
{ | |||
_tcp = new TCPInterface(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Combot | |||
{ | |||
public class Interface | |||
{ | |||
} | |||
} |
@@ -0,0 +1,36 @@ | |||
using System.Reflection; | |||
using System.Runtime.CompilerServices; | |||
using System.Runtime.InteropServices; | |||
// 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("Combot")] | |||
[assembly: AssemblyDescription("")] | |||
[assembly: AssemblyConfiguration("")] | |||
[assembly: AssemblyCompany("")] | |||
[assembly: AssemblyProduct("Combot")] | |||
[assembly: AssemblyCopyright("Copyright © 2014")] | |||
[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 | |||
// 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("c3723677-da3e-4403-80af-ea501f43ceb2")] | |||
// Version information for an assembly consists of the following four values: | |||
// | |||
// Major Version | |||
// Minor Version | |||
// Build Number | |||
// Revision | |||
// | |||
// 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")] | |||
[assembly: AssemblyFileVersion("1.0.0.0")] |
@@ -0,0 +1,124 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.IO; | |||
using System.Net; | |||
using System.Net.Sockets; | |||
using System.Threading; | |||
namespace Combot | |||
{ | |||
class TCPInterface | |||
{ | |||
internal event Action<TCPError> TCPErrorEvent; | |||
internal event Action<int> TCPConnectionEvent; | |||
private IPEndPoint _serverIP = null; | |||
private int _readTimeout = 250; | |||
private Socket _tcpClient; | |||
private NetworkStream _tcpStream; | |||
private int _allowedFailedCount; | |||
private int _currentFailedCount; | |||
internal TCPInterface() | |||
{ | |||
} | |||
internal bool Connect(IPAddress IP, int port, int readTimeout, int allowedFailedCount = 0) | |||
{ | |||
_serverIP = new IPEndPoint(IP, port); | |||
_readTimeout = readTimeout; | |||
_allowedFailedCount = allowedFailedCount; | |||
_currentFailedCount = 0; | |||
try | |||
{ | |||
_tcpClient = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | |||
_tcpClient.Connect(_serverIP); | |||
_tcpClient.ReceiveTimeout = _readTimeout; | |||
_tcpStream = new NetworkStream(_tcpClient); | |||
return true; | |||
} | |||
catch | |||
{ | |||
if (TCPErrorEvent != null) | |||
{ | |||
TCPError error = new TCPError(); | |||
error.Message = string.Format("Unable to connect to {0} on port {1}", _serverIP.Address, _serverIP.Port); | |||
TCPErrorEvent(error); | |||
} | |||
} | |||
return false; | |||
} | |||
internal void Disconnect() | |||
{ | |||
if (_tcpStream != null) | |||
{ | |||
_tcpStream.Close(); | |||
} | |||
if (_tcpClient != null) | |||
{ | |||
_tcpClient.Close(); | |||
} | |||
} | |||
internal void Write(string data) | |||
{ | |||
if (_tcpStream.CanWrite) | |||
{ | |||
byte[] message = System.Text.Encoding.UTF8.GetBytes(data + Environment.NewLine); | |||
_tcpStream.Write(message, 0, message.Length); | |||
} | |||
} | |||
internal string Read() | |||
{ | |||
try | |||
{ | |||
if (_tcpStream.CanRead) | |||
{ | |||
byte[] readBytes = new byte[100000]; | |||
_tcpStream.Read(readBytes, 0, readBytes.Length); | |||
string result = Encoding.UTF8.GetString(readBytes, 0, readBytes.Length); | |||
// Reset Failed Counter | |||
_currentFailedCount = 0; | |||
return result.TrimEnd('\0'); | |||
} | |||
} | |||
catch (IOException) | |||
{ | |||
_currentFailedCount++; | |||
if (TCPErrorEvent != null && _tcpStream.CanRead) | |||
{ | |||
TCPError error = new TCPError(); | |||
error.Message = string.Format("Read Timeout, No Response from Server in {0}ms", _readTimeout); | |||
TCPErrorEvent(error); | |||
} | |||
} | |||
catch (Exception ex) | |||
{ | |||
_currentFailedCount++; | |||
if (TCPErrorEvent != null) | |||
{ | |||
TCPError error = new TCPError(); | |||
error.Message = ex.Message; | |||
TCPErrorEvent(error); | |||
} | |||
} | |||
if (_currentFailedCount > _allowedFailedCount) | |||
{ | |||
if (TCPConnectionEvent != null) | |||
{ | |||
TCPConnectionEvent(_currentFailedCount); | |||
} | |||
Disconnect(); | |||
_currentFailedCount = 0; | |||
} | |||
return null; | |||
} | |||
} | |||
} |
@@ -0,0 +1,14 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace Combot | |||
{ | |||
internal class TCPError | |||
{ | |||
internal int Code { get; set; } | |||
internal string Message { get; set; } | |||
} | |||
} |