Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
d98a496
changed readme locally
bjornSkalkam Sep 15, 2017
d217592
added info to readme.md
bjornSkalkam Sep 15, 2017
37c4d44
Update README.md
bjornSkalkam Oct 9, 2017
8245474
Update README.md
bjornSkalkam Oct 9, 2017
ddf9908
Github test
JosefJensen Oct 22, 2017
208a1e9
her
bjornSkalkam Oct 22, 2017
3b523f8
Sød
JosefJensen Oct 31, 2017
2020e2a
Hjælper mig
JosefJensen Oct 31, 2017
a56bb71
Initial client
Oct 31, 2017
1df2e55
Folder structure
Oct 31, 2017
63321a6
Added server
JosefJensen Oct 31, 2017
4d66e1c
Removed duplicate client
Oct 31, 2017
24a2532
ops
bjornSkalkam Oct 31, 2017
a1dd750
josef wtf u doin
bjornSkalkam Oct 31, 2017
19b2d31
Opened your version. "This binary file has changed." ?????
bjornSkalkam Oct 31, 2017
c141799
Client changes
Oct 31, 2017
0c5eca4
gitignore file
bjornSkalkam Oct 31, 2017
ae83890
Client changes
Oct 31, 2017
01691f6
f off
bjornSkalkam Oct 31, 2017
4794019
Revert "f off"
bjornSkalkam Oct 31, 2017
c953ea7
Revert "Revert "f off""
bjornSkalkam Oct 31, 2017
3543b35
Revert "Revert "Revert "f off"""
bjornSkalkam Oct 31, 2017
a0470e9
Revert "Client changes"
bjornSkalkam Oct 31, 2017
3fd4fb8
Revert "Client changes"
bjornSkalkam Oct 31, 2017
49b3122
???? github wtf
bjornSkalkam Oct 31, 2017
af909d0
gitignore again
bjornSkalkam Oct 31, 2017
ae7f1fd
everything is working again..
bjornSkalkam Oct 31, 2017
5fa31c1
tests
bjornSkalkam Oct 31, 2017
eaa0630
A lot of changes
bjornSkalkam Oct 31, 2017
17954fa
nu skal vi hjem
bjornSkalkam Oct 31, 2017
c9d6390
ID needs to be more than 2 letters fixed
bjornSkalkam Nov 1, 2017
fe31631
fixed more stuff
bjornSkalkam Nov 1, 2017
39931ed
game is working
bjornSkalkam Nov 1, 2017
fbd2bf8
fix
bjornSkalkam Nov 1, 2017
5d6e768
rip comments
bjornSkalkam Nov 1, 2017
70afe3c
idiot
bjornSkalkam Nov 1, 2017
b33621d
now lets do lobby
bjornSkalkam Nov 1, 2017
5173c1a
does this work?
bjornSkalkam Nov 1, 2017
809f26c
Revert "does this work?"
bjornSkalkam Nov 1, 2017
178368f
DET MED HIGHEST NUMBER WINS FUNGERER IKKE. Kan ikke se om det er ford…
bjornSkalkam Nov 1, 2017
a9a805a
cba
bjornSkalkam Nov 1, 2017
1cc510a
everything works on my desktop now :+1:
bjornSkalkam Nov 2, 2017
dcd9e04
imightdemolishaniggarightinfrontya
bjornSkalkam Nov 2, 2017
15cb679
asd
bjornSkalkam Nov 2, 2017
099bae7
Revert "asd"
bjornSkalkam Nov 2, 2017
46d18ab
Revert "imightdemolishaniggarightinfrontya"
bjornSkalkam Nov 2, 2017
e3893e2
Revert "everything works on my desktop now :+1:"
bjornSkalkam Nov 2, 2017
481f651
Revert "cba"
bjornSkalkam Nov 2, 2017
4929370
Revert "DET MED HIGHEST NUMBER WINS FUNGERER IKKE. Kan ikke se om det…
bjornSkalkam Nov 2, 2017
f81c5ea
vi starter forfra med Lobby.
bjornSkalkam Nov 2, 2017
4c76c6d
Giv mig i morgen også, så er jeg færdig med lobby delen
bjornSkalkam Nov 3, 2017
17918fe
får lobbyen til at virke i dag. måske også spillet
bjornSkalkam Nov 3, 2017
5ea4386
now we have a game!
bjornSkalkam Nov 3, 2017
87fafb7
Works. Needs cleanup though.
bjornSkalkam Nov 3, 2017
e36e499
asd
bjornSkalkam Nov 3, 2017
eaabd6b
not needed anymore
bjornSkalkam Nov 3, 2017
f253c02
comment
bjornSkalkam Nov 3, 2017
56ba741
streamlined everything in arrays in the server
bjornSkalkam Nov 3, 2017
d40c3cb
small comment
bjornSkalkam Nov 3, 2017
be85a47
Jeg har smidt alt ind i arrays, så vi kan lave koden meget kortere me…
bjornSkalkam Nov 3, 2017
7c65b0f
ffs
bjornSkalkam Nov 3, 2017
863f7f2
asd
bjornSkalkam Nov 3, 2017
ff71a6b
Revert "asd"
bjornSkalkam Nov 3, 2017
d911a9f
Revert "ffs"
bjornSkalkam Nov 3, 2017
b01650a
Revert "Jeg har smidt alt ind i arrays, så vi kan lave koden meget ko…
bjornSkalkam Nov 3, 2017
1d8dffa
Revert "small comment"
bjornSkalkam Nov 3, 2017
d80b747
Revert "streamlined everything in arrays in the server"
bjornSkalkam Nov 3, 2017
d7f369d
ok fixed
bjornSkalkam Nov 3, 2017
11582b5
is this possible?
bjornSkalkam Nov 3, 2017
f89d9fd
ok works
bjornSkalkam Nov 3, 2017
e0d50ec
added a few comments
bjornSkalkam Nov 3, 2017
54f856f
Revert "is this possible?"
JosefJensen Nov 5, 2017
a47c24c
Revert "Revert "is this possible?""
JosefJensen Nov 5, 2017
ffcc25c
new folder
bjornSkalkam Nov 5, 2017
9d41c53
assignment description
JosefJensen Nov 5, 2017
29a9136
Appropriate name
JosefJensen Nov 5, 2017
344756d
added docs link
bjornSkalkam Nov 5, 2017
595e18e
:100:
bjornSkalkam Nov 5, 2017
b79b8f4
Merge branch 'master' of https://github.com/bjornSkalkam/pcss_group10
JosefJensen Nov 5, 2017
7e7a116
build forfra
bjornSkalkam Nov 5, 2017
489e95d
hello
bjornSkalkam Nov 5, 2017
3c7e5bd
Added Comments To Code
ItsR4vn Nov 6, 2017
671fdea
Added Some Comments
ItsR4vn Nov 6, 2017
a5e3585
more comments
Nov 6, 2017
3d714d3
bit more comments
Nov 6, 2017
c96ed5c
Minor Changes
ItsR4vn Nov 6, 2017
7072f10
Comments
ItsR4vn Nov 6, 2017
282d7ac
Comment Optimization
ItsR4vn Nov 6, 2017
4bca0ce
Comments Changes
ItsR4vn Nov 6, 2017
35d8492
lol woops...
ItsR4vn Nov 6, 2017
3b4017d
More Optimization
ItsR4vn Nov 6, 2017
313091e
Minor Changes
ItsR4vn Nov 6, 2017
432bd27
added some comments. the rest of the code is self explanatory
bjornSkalkam Nov 6, 2017
cd3d09b
her
bjornSkalkam Nov 6, 2017
791dec6
readme.md
bjornSkalkam Nov 6, 2017
efe578b
documentation
mathiasKjeldsen Nov 6, 2017
173a51f
forgot to commit some of my comments xd
bjornSkalkam Nov 6, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
## 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/
[Rr]elease/
x64/
[Bb]in/
[Oo]bj/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*

*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.log
*.svclog
*.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
*.DotSettings.user

# Click-Once directory
publish/

# Publish Web Output
*.Publish.xml
*.pubxml
*.azurePubxml

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
packages/
## TODO: If the tool you use requires repositories.config, also uncomment the next line
!packages/repositories.config

# Windows Azure Build Output
csx/
*.build.csdef

# Windows Store app package directory
AppPackages/

# Others
sql/
*.Cache
ClientBin/
[Ss]tyle[Cc]op.*
![Ss]tyle[Cc]op.targets
~$*
*~
*.dbmdl
*.[Pp]ublish.xml

*.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 desktop service store files
.DS_Store

_NCrunch*
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions ClientServerMultithreading/.vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
9 changes: 9 additions & 0 deletions ClientServerMultithreading/.vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"ExpandedNodes": [
"",
"\\ClientApplication",
"\\ServerApplication"
],
"SelectedNode": "\\ClientApplication\\Program.cs",
"PreviewInSolutionExplorer": false
}
Binary file added ClientServerMultithreading/.vs/slnx.sqlite
Binary file not shown.
6 changes: 6 additions & 0 deletions ClientServerMultithreading/ClientApplication/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<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>{28D2DD87-9A8B-476E-A467-1E70D696FD3D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ClientApplication</RootNamespace>
<AssemblyName>ClientApplication</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="NetworkCommsDotNetComplete">
<HintPath>..\NetworkCommsDotNetComplete.dll</HintPath>
</Reference>
<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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</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>
115 changes: 115 additions & 0 deletions ClientServerMultithreading/ClientApplication/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@

// Using Directive List
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;

// Creating The public class "EchoClient"
public class EchoClient {

// MAXIMUM 3 CLIENTS SUPPORTED

// Calling static variables
static bool selectedName = false;
static bool joinedLobby = false;
static int lobbyNumber = 0;
static String clientName = "";
static bool startingGame = false;


public static void Main() {
try { // try-catch Tries To Catch Exceptions And Prints It Out If Something Goes Wrong In The Program
TcpClient client = new TcpClient("127.0.0.1", 10000); // Client IP and port, 127.0.0.1 is localhost
StreamReader reader = new StreamReader(client.GetStream()); // For Reading Data From The Server
StreamWriter writer = new StreamWriter(client.GetStream()); // For Writing Data To The Server
String s = String.Empty; // String s Is Used To Temporarily Store What Is Input Into The Console
while (!s.Equals("Exit")) {
if (!selectedName) {
Console.WriteLine("Connected to server! \n"); // Outputs Message To Console
Console.Write("Hello There! Please select a unique screen name: "); // Outputs Message To Console
clientName = Console.ReadLine(); // Write The Screen Name You Want
s = "++"+clientName; // Store It In The String - the ++ is added before it's sent so the server can identify it later

selectedName = true;
while (clientName.Length < 2) { // String Length Need To Be Larger Than 2
Console.WriteLine("Your unique screen name needs to be longer. \n");
Console.Write("Hello There! Please select a unique screen name: ");
clientName = Console.ReadLine();
s = "++"+clientName;
}
} else if (selectedName && !joinedLobby && !startingGame) { // If You Selected A Name But Did Not Join And/Or Start A Game Yet
Console.WriteLine("Here are your options: \n");
Console.WriteLine("lobbylist: View list of lobbies");
Console.WriteLine("open 1-3: create new lobby");
Console.WriteLine("close 1-3: close lobby");
Console.WriteLine("join 1-3: join lobby \n");

s = clientName+"_"+Console.ReadLine(); //the client name and an underscore is added before it's sent so the server can identify it
}


if (joinedLobby && !startingGame) { // If You Joined A Lobby But Did Not Start The Game Yet
Console.WriteLine("Waiting for game to start.");
Console.WriteLine("You are in lobby " + lobbyNumber);
Console.WriteLine("Type leave to leave the lobby.");
Console.WriteLine("Press Enter to update the state of the lobby. \n");
s = clientName+"_"+Console.ReadLine(); //the client name and an underscore is added before it's sent so the server can identify it
}


if (startingGame) { // If A Game Has Started
Console.WriteLine("Starting Game! Press enter to see who won! \n \n");
s = Console.ReadLine()+"xox9_"; //random numbers xox9_ added at the end so the server can identify it
//Console.WriteLine("Sending this input: " + s);
}

Console.WriteLine();
writer.WriteLine(s); // Sends Input To The Server
writer.Flush(); // Flushes The Streamreader

String server_string = reader.ReadLine(); // Streamreader To Receive Data/Information From The Server
Console.WriteLine("From Server: " + server_string + "\n");

/*
Below Code Checks Which Lobby The Player Is Connected To,
How Many Other Players Are Connected And If The Game Is Ready To Start
It Receives Strings From The Server According To Which Other Players Joined The Game etc.
This Happens via The String server_string streamreader (because the server can only send one line at a time, we make the clients print the code)
*/

if (server_string == "Joined lobby 1 (1)" || server_string == "Joined lobby 1 (2)") {
joinedLobby = true;
lobbyNumber = 1;
} else if (server_string == "Joined lobby 1 (3)" || server_string == "3 Players connected to lobby 1! Ready to start game!") {
joinedLobby = true;
lobbyNumber = 1;
startingGame = true;
}

if (server_string == "Joined lobby 2 (1)" || server_string == "Joined lobby 2 (2)") {
joinedLobby = true;
lobbyNumber = 2;
} else if (server_string == "Joined lobby 2 (3)" || server_string == "3 Players connected to lobby 2! Ready to start game!") {
joinedLobby = true;
lobbyNumber = 2;
startingGame = true;
}

if (server_string == "Joined lobby 3 (1)" || server_string == "Joined lobby 3 (2)") {
joinedLobby = true;
lobbyNumber = 3;
} else if (server_string == "Joined lobby 3 (3)" || server_string == "3 Players connected to lobby 3! Ready to start game!") {
joinedLobby = true;
lobbyNumber = 3;
startingGame = true;
}
}
reader.Close(); // Called To Close Reader After The Game Has Ended
writer.Close(); // Called To Close Writer After The Game Has Ended
client.Close(); // Called To Close The Client After The Game Has Ended
} catch (Exception e) { // If There Are Any Errors ...
Console.WriteLine(e); // Output Them To The Console
}
}
}
Original file line number Diff line number Diff line change
@@ -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("ClientApplication")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ClientApplication")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[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("28d2dd87-9a8b-476e-a467-1e70d696fd3d")]

// 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")]
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Loading