This commit is contained in:
Yorick Rommers
2015-10-15 13:42:56 +02:00
3 changed files with 10 additions and 4 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
using MusicPlayer; using MusicPlayer;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace WindowsFormsApplication2 namespace MusicPlayer
{ {
internal class APIHandler internal class APIHandler
{ {
+7 -3
View File
@@ -2,17 +2,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)
@@ -26,7 +28,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);
} }
} }
} }