Merge branch 'developer' into gui

This commit is contained in:
2015-10-29 19:55:45 +01:00
5 changed files with 83 additions and 23 deletions
+48
View File
@@ -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
}
}
+6
View File
@@ -18,6 +18,12 @@ namespace MusicPlayer
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
// nw.SendString("GET / HTTP/1.1");
}
private void Form1_Load(object sender, EventArgs e)
{
//APIHandler api = new APIHandler(); //APIHandler api = new APIHandler();
//NetworkHandler nw = new NetworkHandler("83.128.250.123", api); //NetworkHandler nw = new NetworkHandler("83.128.250.123", api);
table = new SongsTable(); table = new SongsTable();
+3 -3
View File
@@ -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"> <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')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
@@ -46,7 +46,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="MainForm.cs"> <Compile Include="MainForm.cs" >
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Album.cs" /> <Compile Include="Album.cs" />
@@ -95,4 +95,4 @@
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
+23 -20
View File
@@ -1,41 +1,44 @@
using System.Text; using System;
using System.Text;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using System.Net;
using System.IO;
namespace MusicPlayer namespace MusicPlayer
{ {
class NetworkHandler class NetworkHandler
{ {
private int port = 8585; private int port = 8585;
private Socket s; private string ip;
private APIHandler api; private APIHandler api;
public NetworkHandler(string ip, APIHandler apihandler) public NetworkHandler(string ip, APIHandler apihandler)
{ {
s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); this.ip = ip;
s.Connect(ip, port); this.api = apihandler;
ThreadStart thread = new ThreadStart(ReceiveData);
Thread childThread = new Thread(thread);
childThread.Start();
api = apihandler;
} }
public void SendString(string m) public void SendString(string m)
{ {
byte[] req_as_bytes = Encoding.UTF8.GetBytes(m); HttpWebRequest server = (HttpWebRequest)WebRequest.Create(ip+":"+port+"/"+m);
s.Send(req_as_bytes); server.KeepAlive = false;
} HttpWebResponse respond = (HttpWebResponse)server.GetResponse();
Stream streamResponse = respond.GetResponseStream();
public void ReceiveData() StreamReader streamRead = new StreamReader(streamResponse);
{ Char[] readBuff = new Char[256];
while (s.Connected) int count = streamRead.Read(readBuff, 0, 256);
string data = "";
while (count > 0)
{ {
byte[] data = new byte[1024 * 200]; String outputData = new String(readBuff, 0, count);
s.Receive(data); data +=outputData;
string message = Encoding.ASCII.GetString(data); count = streamRead.Read(readBuff, 0, 256);
System.Console.WriteLine(message);
//Iets doen met api calls
} }
System.Console.WriteLine(data);
respond.Close();
streamResponse.Close();
streamRead.Close();
} }
} }
} }
+3
View File
@@ -14,6 +14,9 @@ namespace MusicPlayer
[STAThread] [STAThread]
static void Main() static void Main()
{ {
APIHandler api = new APIHandler();
NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl", api);
nw.SendString("getsongbyid?id=102");
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm()); Application.Run(new MainForm());