Addes some functionality to networkhandler, fixed wrong namespace

This commit is contained in:
jancoow
2015-10-15 13:41:27 +02:00
parent af735a8502
commit 9364ebddc4
3 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace WindowsFormsApplication2 namespace MusicPlayer
{ {
class APIHandler class APIHandler
{ {
+7 -3
View File
@@ -1,17 +1,19 @@
using System.Text; using System.Text;
using System.Net.Sockets; using System.Net.Sockets;
namespace WindowsFormsApplication2 namespace MusicPlayer
{ {
class NetworkHandler class NetworkHandler
{ {
private int port = 8585; private int port = 8585;
private Socket s; private Socket s;
private APIHandler api;
public NetworkHandler(string ip) public NetworkHandler(string ip, APIHandler apihandler)
{ {
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
s.Connect(ip, port); s.Connect(ip, port);
api = apihandler;
} }
public void SendString(string m) public void SendString(string m)
@@ -25,7 +27,9 @@ namespace WindowsFormsApplication2
while (s.Connected) while (s.Connected)
{ {
byte[] data = new byte[1024 * 200]; byte[] data = new byte[1024 * 200];
int t = s.Receive(data); s.Receive(data);
string message = Encoding.ASCII.GetString(data);
System.Console.WriteLine(message);
//Iets doen met api calls //Iets doen met api calls
} }
} }
+2
View File
@@ -17,6 +17,8 @@ namespace MusicPlayer
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); Application.Run(new Form1());
APIHandler a = new APIHandler;
NetworkHandler nw = new NetworkHandler("imegumii.nl", a);
} }
} }
} }