Werkt nog niet
This commit is contained in:
+10
-1
@@ -28,9 +28,18 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(284, 261);
|
||||
this.Name = "Form1";
|
||||
this.Text = "Form1";
|
||||
this.Load += new System.EventHandler(this.Form1_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -16,8 +16,12 @@ namespace MusicPlayer
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
APIHandler api = new APIHandler();
|
||||
NetworkHandler nw = new NetworkHandler("83.128.250.123", api);
|
||||
// nw.SendString("GET / HTTP/1.1");
|
||||
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
<Compile Include="NetworkHandler.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
|
||||
@@ -7,13 +8,16 @@ namespace MusicPlayer
|
||||
class NetworkHandler
|
||||
{
|
||||
private int port = 8585;
|
||||
private Socket s;
|
||||
private TcpClient s;
|
||||
private NetworkStream serverStream;
|
||||
private APIHandler api;
|
||||
|
||||
public NetworkHandler(string ip, APIHandler apihandler)
|
||||
{
|
||||
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
Console.WriteLine("Hello");
|
||||
s = new TcpClient();
|
||||
s.Connect(ip, port);
|
||||
serverStream = s.GetStream();
|
||||
ThreadStart thread = new ThreadStart(ReceiveData);
|
||||
Thread childThread = new Thread(thread);
|
||||
childThread.Start();
|
||||
@@ -21,17 +25,25 @@ namespace MusicPlayer
|
||||
}
|
||||
|
||||
public void SendString(string m)
|
||||
{
|
||||
byte[] req_as_bytes = Encoding.UTF8.GetBytes(m);
|
||||
s.Send(req_as_bytes);
|
||||
{
|
||||
byte[] b = Encoding.UTF8.GetBytes(m);
|
||||
serverStream.Write(b, 0, b.Length);
|
||||
serverStream.Flush();
|
||||
}
|
||||
|
||||
public void ReceiveData()
|
||||
{
|
||||
Console.WriteLine("Hello2");
|
||||
while (s.Connected)
|
||||
{
|
||||
byte[] data = new byte[1024 * 200];
|
||||
s.Receive(data);
|
||||
Console.WriteLine("Hello3");
|
||||
byte[] data = new byte[512];
|
||||
Console.WriteLine("Hang je hier?");
|
||||
int bytesRec = serverStream.Read(data, 0, data.Length);
|
||||
Console.WriteLine("ën hier? ");
|
||||
Console.WriteLine("Echoed test = {0}",Encoding.ASCII.GetString(data, 0, bytesRec));
|
||||
|
||||
|
||||
string message = Encoding.ASCII.GetString(data);
|
||||
System.Console.WriteLine(message);
|
||||
//Iets doen met api calls
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace MusicPlayer
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
APIHandler api = new APIHandler();
|
||||
NetworkHandler nw = new NetworkHandler("www.imegumii.nl", api);
|
||||
nw.SendString("GET /getsongbyid?id=102 HTTP/1.1");
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
|
||||
Reference in New Issue
Block a user