Forráskód Böngészése

Added start of networkhandler and apihandler

jancoow 10 éve
szülő
commit
72c75b457d

+ 12 - 0
MusicPlayer/MusicPlayer/APIHandler.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WindowsFormsApplication2
+{
+    class APIHandler
+    {
+    }
+}

+ 33 - 0
MusicPlayer/MusicPlayer/NetworkHandler.cs

@@ -0,0 +1,33 @@
+using System.Text;
+using System.Net.Sockets;
+
+namespace WindowsFormsApplication2
+{
+    class NetworkHandler
+    {
+        private int port = 8585;
+        private Socket s;
+ 
+        public NetworkHandler(string ip)
+        {
+            s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+            s.Connect(ip, port);
+        }
+
+        public void SendString(string m)
+        {
+            byte[] req_as_bytes = Encoding.UTF8.GetBytes(m);
+            s.Send(req_as_bytes);
+        }
+
+        public void ReceiveData()
+        {
+            while (s.Connected)
+            {
+                byte[] data = new byte[1024 * 200]; 
+                int t = s.Receive(data);
+                //Iets doen met api calls
+            }
+        }
+    }
+}