Merge branch 'developer' into gui
This commit is contained in:
+48
@@ -0,0 +1,48 @@
|
||||
namespace MusicPlayer
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,12 @@ namespace MusicPlayer
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
// nw.SendString("GET / HTTP/1.1");
|
||||
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
//APIHandler api = new APIHandler();
|
||||
//NetworkHandler nw = new NetworkHandler("83.128.250.123", api);
|
||||
table = new SongsTable();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?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>
|
||||
@@ -46,7 +46,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainForm.cs">
|
||||
<Compile Include="MainForm.cs" >
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Album.cs" />
|
||||
@@ -95,4 +95,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -1,41 +1,44 @@
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
|
||||
namespace MusicPlayer
|
||||
{
|
||||
class NetworkHandler
|
||||
{
|
||||
private int port = 8585;
|
||||
private Socket s;
|
||||
private string ip;
|
||||
private APIHandler api;
|
||||
|
||||
public NetworkHandler(string ip, APIHandler apihandler)
|
||||
{
|
||||
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
s.Connect(ip, port);
|
||||
ThreadStart thread = new ThreadStart(ReceiveData);
|
||||
Thread childThread = new Thread(thread);
|
||||
childThread.Start();
|
||||
api = apihandler;
|
||||
this.ip = ip;
|
||||
this.api = apihandler;
|
||||
}
|
||||
|
||||
public void SendString(string m)
|
||||
{
|
||||
byte[] req_as_bytes = Encoding.UTF8.GetBytes(m);
|
||||
s.Send(req_as_bytes);
|
||||
}
|
||||
|
||||
public void ReceiveData()
|
||||
{
|
||||
while (s.Connected)
|
||||
HttpWebRequest server = (HttpWebRequest)WebRequest.Create(ip+":"+port+"/"+m);
|
||||
server.KeepAlive = false;
|
||||
HttpWebResponse respond = (HttpWebResponse)server.GetResponse();
|
||||
Stream streamResponse = respond.GetResponseStream();
|
||||
StreamReader streamRead = new StreamReader(streamResponse);
|
||||
Char[] readBuff = new Char[256];
|
||||
int count = streamRead.Read(readBuff, 0, 256);
|
||||
string data = "";
|
||||
while (count > 0)
|
||||
{
|
||||
byte[] data = new byte[1024 * 200];
|
||||
s.Receive(data);
|
||||
string message = Encoding.ASCII.GetString(data);
|
||||
System.Console.WriteLine(message);
|
||||
//Iets doen met api calls
|
||||
String outputData = new String(readBuff, 0, count);
|
||||
data +=outputData;
|
||||
count = streamRead.Read(readBuff, 0, 256);
|
||||
}
|
||||
System.Console.WriteLine(data);
|
||||
respond.Close();
|
||||
streamResponse.Close();
|
||||
streamRead.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ namespace MusicPlayer
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
APIHandler api = new APIHandler();
|
||||
NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl", api);
|
||||
nw.SendString("getsongbyid?id=102");
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new MainForm());
|
||||
|
||||
Reference in New Issue
Block a user