Add project files.
51
PolyChat.sln
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.31624.102
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PolyChat", "PolyChat\PolyChat.csproj", "{23ACF793-F4C9-48C2-893C-7BD4A601EF40}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|ARM = Release|ARM
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|ARM.ActiveCfg = Debug|ARM
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|ARM.Build.0 = Debug|ARM
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|ARM.Deploy.0 = Debug|ARM
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|ARM64.Deploy.0 = Debug|ARM64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|x64.Build.0 = Debug|x64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|x86.Build.0 = Debug|x86
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|ARM.ActiveCfg = Release|ARM
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|ARM.Build.0 = Release|ARM
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|ARM.Deploy.0 = Release|ARM
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|ARM64.Deploy.0 = Release|ARM64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|x64.ActiveCfg = Release|x64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|x64.Build.0 = Release|x64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|x64.Deploy.0 = Release|x64
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|x86.ActiveCfg = Release|x86
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|x86.Build.0 = Release|x86
|
||||
{23ACF793-F4C9-48C2-893C-7BD4A601EF40}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {58B9261A-B53D-4C9F-B1C5-D3855184F5B1}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
6
PolyChat/App.xaml
Normal file
@@ -0,0 +1,6 @@
|
||||
<Application
|
||||
x:Class="PolyChat.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:PolyChat">
|
||||
</Application>
|
||||
100
PolyChat/App.xaml.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace PolyChat
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == null)
|
||||
{
|
||||
// Create a Frame to act as the navigation context and navigate to the first page
|
||||
rootFrame = new Frame();
|
||||
|
||||
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||
|
||||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||
{
|
||||
//TODO: Load state from previously suspended application
|
||||
}
|
||||
|
||||
// Place the frame in the current Window
|
||||
Window.Current.Content = rootFrame;
|
||||
}
|
||||
|
||||
if (e.PrelaunchActivated == false)
|
||||
{
|
||||
if (rootFrame.Content == null)
|
||||
{
|
||||
// When the navigation stack isn't restored navigate to the first page,
|
||||
// configuring the new page by passing required information as a navigation
|
||||
// parameter
|
||||
rootFrame.Navigate(typeof(MainPage), e.Arguments);
|
||||
}
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when Navigation to a certain page fails
|
||||
/// </summary>
|
||||
/// <param name="sender">The Frame which failed navigation</param>
|
||||
/// <param name="e">Details about the navigation failure</param>
|
||||
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when application execution is being suspended. Application state is saved
|
||||
/// without knowing whether the application will be terminated or resumed with the contents
|
||||
/// of memory still intact.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the suspend request.</param>
|
||||
/// <param name="e">Details about the suspend request.</param>
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
PolyChat/Assets/LockScreenLogo.scale-200.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
PolyChat/Assets/SplashScreen.scale-200.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
BIN
PolyChat/Assets/Square150x150Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
BIN
PolyChat/Assets/Square44x44Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
BIN
PolyChat/Assets/StoreLogo.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
PolyChat/Assets/Wide310x150Logo.scale-200.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
104
PolyChat/Controller.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using EngineIOSharp.Common.Enum;
|
||||
using PolyChat.Models;
|
||||
using PolyChat.Models.Exceptions;
|
||||
using SocketIOSharp.Client;
|
||||
using SocketIOSharp.Common;
|
||||
using SocketIOSharp.Common.Packet;
|
||||
using SocketIOSharp.Server.Client;
|
||||
|
||||
namespace PolyChat
|
||||
{
|
||||
public class Controller
|
||||
{
|
||||
public static IPAddress ip;
|
||||
private MainPage UIController;
|
||||
|
||||
private ClientHandler clientHandler;
|
||||
public Controller(MainPage uiController)
|
||||
{
|
||||
UIController = uiController;
|
||||
clientHandler = new ClientHandler();
|
||||
Socket s = new Socket(this);
|
||||
}
|
||||
|
||||
public void Connect(string ip)
|
||||
{
|
||||
clientHandler.connectNewClient(ip);
|
||||
}
|
||||
|
||||
public void sendMessage(String ip, String name, String msg)
|
||||
{
|
||||
clientHandler.getClient(ip).sendMessage(SendCode.Message, name, msg, DateTime.Now);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// prints out ip. on server side automatticaly finds 10.... ip (which is the correct one)
|
||||
/// </summary>
|
||||
/// <returns>users ip</returns>
|
||||
private String getIP()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
string input = Console.ReadLine();
|
||||
if (input.Equals("server"))
|
||||
{
|
||||
Console.WriteLine("starting as server...");
|
||||
for (short i = 0; i < GetIPs().Length; i++)
|
||||
{
|
||||
if (GetIPs()[i].ToString().Substring(0, 3).Equals("10."))
|
||||
{
|
||||
Controller.ip = GetIPs()[i];
|
||||
Console.WriteLine(GetIPs()[i]);
|
||||
//get ip as byte array
|
||||
byte[] ba = System.Text.Encoding.ASCII.GetBytes(GetIPs()[i].ToString());
|
||||
foreach (var item in ba)
|
||||
{
|
||||
Console.Write(item.ToString() + ",");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
Socket s = new Socket(this);
|
||||
}
|
||||
else if (input.Equals("client"))
|
||||
{
|
||||
ClientHandler cl = new ClientHandler();
|
||||
Console.WriteLine("Enter IP:");
|
||||
cl.connectNewClient(Console.ReadLine());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void InitEventHandlers(SocketIOClient client)
|
||||
{
|
||||
client.On(SocketIOEvent.CONNECTION, () =>
|
||||
{
|
||||
Console.WriteLine("Connected!");
|
||||
client.Emit("Message", "This is a Message Body!");
|
||||
});
|
||||
|
||||
client.On(SocketIOEvent.DISCONNECT, () =>
|
||||
{
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Disconnected!");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void OnMessageCallback(SocketIOSocket socket, SocketIOAckEvent message)
|
||||
{
|
||||
Console.WriteLine($"Message received from {socket.GetHashCode()}:{message.Data[0]}");
|
||||
}
|
||||
|
||||
static IPAddress[] GetIPs()
|
||||
{
|
||||
IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName());
|
||||
IPAddress[] addr = ipEntry.AddressList;
|
||||
return addr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
114
PolyChat/MainPage.xaml
Normal file
@@ -0,0 +1,114 @@
|
||||
<Page
|
||||
x:Class="PolyChat.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:models="using:PolyChat.Models"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="224"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- LEFT SIDE -->
|
||||
<Grid Grid.Column="0" Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!-- CONNECTION HEADER -->
|
||||
<StackPanel HorizontalAlignment="Stretch">
|
||||
<Grid Margin="0 0 0 8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Margin="0 0 8 0" Text="Connect to"/>
|
||||
<TextBlock x:Name="ipAddress" Grid.Column="1"/>
|
||||
</Grid>
|
||||
<TextBox x:Name="inputUsername" Header="Displayed Name" PlaceholderText="Robert Bosch" Margin="0 0 0 8"/>
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="My Chats" VerticalAlignment="Center"/>
|
||||
<Button Grid.Column="1" Click="OnOpenNewChatDialog" Content="New"/>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<!-- CHATS LIST -->
|
||||
<ScrollViewer Grid.Row="1" HorizontalAlignment="Stretch" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
|
||||
<ListView x:Name="listViewPartners" ItemsSource="{x:Bind Partners}" HorizontalAlignment="Stretch" Margin="0 8 0 0">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:ChatPartner">
|
||||
<RadioButton GroupName="chatSelect" Tag="{x:Bind Code}" HorizontalAlignment="Stretch" Height="64" Checked="OnChatPartnerSelected">
|
||||
<StackPanel x:Name="ChatPartner" VerticalAlignment="Center" HorizontalAlignment="Stretch">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||
<TextBlock HorizontalAlignment="Stretch" Text="{x:Bind Name}"/>
|
||||
<TextBlock Text=" ("/>
|
||||
<TextBlock Text="{x:Bind Code}"/>
|
||||
<TextBlock Text=")"/>
|
||||
</StackPanel>
|
||||
<!--
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
|
||||
<TextBlock HorizontalAlignment="Stretch" Text="{x:Bind Messages.Last().toString()}"/>
|
||||
<TextBlock Text="{x:Bind Messages.Last().Date}"/>
|
||||
</StackPanel>
|
||||
-->
|
||||
</StackPanel>
|
||||
</RadioButton>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
<!-- RIGHT SIDE -->
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="64"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="64"/>
|
||||
</Grid.RowDefinitions>
|
||||
<!-- CHAT HEADER LEFT & RIGHT -->
|
||||
<Grid Padding="16 0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock x:Name="selectedPartnerName" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Column="1">
|
||||
<Button Click="OnDeleteChat" Content="Delete Chat"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<!-- CHAT -->
|
||||
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden">
|
||||
<ListView x:Name="listViewMessages" VerticalAlignment="Bottom" Margin="4 16">
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate x:DataType="models:ChatMessage">
|
||||
<StackPanel x:Name="Message" Margin="0 4" Padding="16 8" CornerRadius="4" Background="{ThemeResource SystemAccentColor}">
|
||||
<TextBlock Text="{x:Bind Text}"/>
|
||||
<TextBlock Text="{x:Bind Date}"/>
|
||||
<TextBlock Text="{x:Bind Foreign}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</ScrollViewer>
|
||||
<!-- CHAT INPUT & SEND -->
|
||||
<Grid Grid.Row="2" Margin="16 0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="inputSend" KeyDown="OnKeyDown" PlaceholderText="My message" VerticalAlignment="Center"/>
|
||||
<StackPanel Orientation="Horizontal" Grid.Column="1">
|
||||
<Button Content="Send" Click="OnSendMessage"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
||||
88
PolyChat/MainPage.xaml.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using PolyChat.Models;
|
||||
using PolyChat.Views;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
namespace PolyChat
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
private Controller Controller;
|
||||
private ObservableCollection<ChatPartner> Partners;
|
||||
private ChatPartner selectedPartner;
|
||||
public MainPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
Controller = new Controller(this);
|
||||
|
||||
Partners = new ObservableCollection<ChatPartner>();
|
||||
}
|
||||
|
||||
public void OnChatPartnerSelected(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string code = ((RadioButton)sender).Tag.ToString();
|
||||
selectedPartner = Partners.First(p => p.Code == code);
|
||||
listViewMessages.ItemsSource = selectedPartner.Messages;
|
||||
selectedPartnerName.Text = selectedPartner.Name;
|
||||
}
|
||||
|
||||
public void OnSendMessage(object sender = null, RoutedEventArgs e = null)
|
||||
{
|
||||
selectedPartner.AddMessage(new ChatMessage(
|
||||
inputSend.Text,
|
||||
DateTime.Now.ToString(),
|
||||
false
|
||||
));
|
||||
Controller.sendMessage(selectedPartner.Code, inputUsername.Text, inputSend.Text);
|
||||
// clear input
|
||||
inputSend.Text = "";
|
||||
}
|
||||
|
||||
public async void OnOpenNewChatDialog(object sender = null, RoutedEventArgs e = null)
|
||||
{
|
||||
NewChatDialog dialog = new NewChatDialog();
|
||||
var result = await dialog.ShowAsync();
|
||||
if (result == ContentDialogResult.Primary)
|
||||
{
|
||||
string ip = dialog.getText();
|
||||
Controller.Connect(ip);
|
||||
Partners.Add(new ChatPartner(
|
||||
"NO NAME",
|
||||
ip
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnIncomingMessage(MSG message)
|
||||
{
|
||||
ChatPartner sendingPartner = Partners.First(p => p.Code == message.ip.ToString());
|
||||
sendingPartner.AddMessage(new ChatMessage(
|
||||
message.msg,
|
||||
message.timestamp.ToString(),
|
||||
true
|
||||
));
|
||||
}
|
||||
|
||||
private void OnDeleteChat(object sender = null, RoutedEventArgs e = null)
|
||||
{
|
||||
Partners.Remove(selectedPartner);
|
||||
}
|
||||
|
||||
private void OnKeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
|
||||
{
|
||||
if (e.Key == Windows.System.VirtualKey.Enter)
|
||||
{
|
||||
OnSendMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
PolyChat/Models/ChatMessage.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace PolyChat.Models
|
||||
{
|
||||
public class ChatMessage
|
||||
{
|
||||
public string Text;
|
||||
public string Date;
|
||||
public bool Foreign;
|
||||
|
||||
public ChatMessage(string text, string date, bool foreign)
|
||||
{
|
||||
Text = text;
|
||||
Date = date;
|
||||
Foreign = foreign;
|
||||
}
|
||||
|
||||
override
|
||||
public string ToString()
|
||||
{
|
||||
string prefix = Foreign ? "Other" : "Me";
|
||||
return $"{prefix}: Text";
|
||||
}
|
||||
}
|
||||
}
|
||||
28
PolyChat/Models/ChatPartner.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using SocketIOSharp.Server.Client;
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace PolyChat.Models
|
||||
{
|
||||
public class ChatPartner
|
||||
{
|
||||
public string Name;
|
||||
public string Code;
|
||||
public ObservableCollection<ChatMessage> Messages;
|
||||
private SocketIOSocket socketIOSocket;
|
||||
|
||||
public ChatPartner(string name, string code, ObservableCollection<ChatMessage> messages = null)
|
||||
{
|
||||
Name = name;
|
||||
Code = code;
|
||||
if (messages == null) Messages = new ObservableCollection<ChatMessage>();
|
||||
else Messages = messages;
|
||||
}
|
||||
|
||||
public SocketIOSocket SocketIOSocket { get => socketIOSocket; set => socketIOSocket = value; }
|
||||
|
||||
public void AddMessage(ChatMessage message)
|
||||
{
|
||||
Messages.Add(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
110
PolyChat/Models/Client.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SocketIOSharp.Common;
|
||||
using SocketIOSharp.Server;
|
||||
using SocketIOSharp.Client;
|
||||
using SocketIOSharp.Server.Client;
|
||||
using EngineIOSharp.Common.Enum;
|
||||
using Json.Net;
|
||||
using System.Net;
|
||||
using SocketIOSharp.Client;
|
||||
using SocketIOSharp.Common;
|
||||
using SocketIOSharp.Common.Packet;
|
||||
using System;
|
||||
using System.Net;
|
||||
using EngineIOSharp.Common.Enum;
|
||||
using System.Threading;
|
||||
|
||||
namespace PolyChat.Models
|
||||
{
|
||||
class Client
|
||||
{
|
||||
private SocketIOClient connection;
|
||||
public Boolean isConnected = false;
|
||||
private List<MSG> msgStack = new List<MSG>();
|
||||
private Boolean active = true;
|
||||
private String ip;
|
||||
|
||||
public Client(SocketIOClient connection, String ip)
|
||||
{
|
||||
this.ip = ip;
|
||||
this.connection = connection;
|
||||
InitEventHandlers(this, connection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// converts String message into json file and sends it to the server.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// gets called by gui if someone wants to send Message
|
||||
/// </remarks>
|
||||
/// <param name="sender">Sender of Message</param>
|
||||
/// <param name="chatMessage">the accual text the user wants to send</param>
|
||||
/// <param name="timestamp">current time</param>
|
||||
public void sendMessage(SendCode code, String sender, String chatMessage, DateTime timestamp)
|
||||
{
|
||||
new Thread(() =>
|
||||
{
|
||||
//create msg
|
||||
MSG msg = new MSG(sender, Controller.ip, chatMessage, timestamp);
|
||||
|
||||
//convert msg
|
||||
String petJson = JsonNet.Serialize(msg);
|
||||
|
||||
//send msg
|
||||
connection.Emit(code.ToString(), petJson);
|
||||
}).Start();
|
||||
}
|
||||
|
||||
/*
|
||||
private void recieveMessage(String msg)
|
||||
{
|
||||
// deserialize json string
|
||||
MSG pet = JsonNet.Deserialize<MSG>(msg);
|
||||
|
||||
//TODO: send message to GUI
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// handles all events of client server communiation
|
||||
/// </summary>
|
||||
/// <param name="client">self</param>
|
||||
/// <param name="connection"></param>
|
||||
private static void InitEventHandlers(Client client, SocketIOClient connection)
|
||||
{
|
||||
connection.On(SendCode.Message.ToString(), (Data) =>
|
||||
{
|
||||
MSG pet = JsonNet.Deserialize<MSG>(BitConverter.ToString(Data[0].ToObject<byte[]>()));
|
||||
//TODO: send message to GUI
|
||||
});
|
||||
connection.On(SendCode.Command.ToString(), (Data) =>
|
||||
{
|
||||
Console.WriteLine("Command recieved!" + Data[0]);
|
||||
});
|
||||
connection.On(SendCode.test1.ToString(), (Data) =>
|
||||
{
|
||||
Console.WriteLine("test1 recieved!" + Data[0]);
|
||||
});
|
||||
connection.On(SendCode.test2.ToString(), (Data) =>
|
||||
{
|
||||
Console.WriteLine("test2 recieved!" + Data[0]);
|
||||
});
|
||||
|
||||
connection.On(SocketIOEvent.CONNECTION, () =>
|
||||
{
|
||||
Console.WriteLine("Connected!");
|
||||
client.isConnected = true;
|
||||
});
|
||||
}
|
||||
|
||||
public String getIP()
|
||||
{
|
||||
return this.ip;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
53
PolyChat/Models/ClientHandler.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SocketIOSharp.Common;
|
||||
using SocketIOSharp.Server;
|
||||
using SocketIOSharp.Client;
|
||||
using SocketIOSharp.Server.Client;
|
||||
using EngineIOSharp.Common.Enum;
|
||||
using Json.Net;
|
||||
|
||||
namespace PolyChat.Models
|
||||
{
|
||||
class ClientHandler
|
||||
{
|
||||
public List<Client> clients = new List<Client>();
|
||||
public ClientHandler()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// connects new clients and saves them in list
|
||||
/// </summary>
|
||||
/// <param name="clientCode">ip adress of parter</param>
|
||||
public void connectNewClient(String clientCode)
|
||||
{
|
||||
//Todo: convert code into ip
|
||||
|
||||
SocketIOClient connection = new SocketIOClient(new SocketIOClientOption(EngineIOScheme.http, clientCode, 8050));
|
||||
connection.Connect();
|
||||
clients.Add(new Client(connection, clientCode));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns client that fits to ip adress
|
||||
/// </summary>
|
||||
/// <param name="ip"></param>
|
||||
/// <returns></returns>
|
||||
public Client getClient(String ip)
|
||||
{
|
||||
foreach (Client cl in clients)
|
||||
{
|
||||
if (cl.getIP().Equals(ip))
|
||||
{
|
||||
return cl;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
13
PolyChat/Models/Exceptions/ConnectionFailedException.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PolyChat.Models.Exceptions
|
||||
{
|
||||
public class ConnectionFailedException : Exception
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
29
PolyChat/Models/MSG.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PolyChat.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// dumy class for json converter
|
||||
/// </summary>
|
||||
public class MSG
|
||||
{
|
||||
public String sender = "unknown";
|
||||
public DateTime timestamp = new DateTime(2000, 01, 01);
|
||||
public String msg = "empty";
|
||||
public IPAddress ip = new IPAddress(new byte[] { 49,48,46,49,46,50,49,49,46,50,54 });
|
||||
|
||||
|
||||
public MSG(String sender, IPAddress ip, String msg, DateTime timestamp)
|
||||
{
|
||||
this.sender = sender;
|
||||
this.ip = ip;
|
||||
this.timestamp = timestamp;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
}
|
||||
10
PolyChat/Models/SendCode.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace PolyChat.Models
|
||||
{
|
||||
enum SendCode
|
||||
{
|
||||
Message,
|
||||
Command,
|
||||
test1,
|
||||
test2
|
||||
}
|
||||
}
|
||||
53
PolyChat/Models/Socket.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Json.Net;
|
||||
using SocketIOSharp.Common;
|
||||
using SocketIOSharp.Server;
|
||||
using SocketIOSharp.Server.Client;
|
||||
|
||||
namespace PolyChat.Models
|
||||
{
|
||||
class Socket
|
||||
{
|
||||
private Controller p;
|
||||
private readonly ushort Port;
|
||||
private SocketIOServer Server;
|
||||
private List<SocketIOSocket> Sockets = new List<SocketIOSocket>();
|
||||
|
||||
/// <summary>
|
||||
/// creates server on specified port
|
||||
/// </summary>
|
||||
/// <param name="Port"></param>
|
||||
public Socket(Controller p, ushort Port = 8050)
|
||||
{
|
||||
this.Port = Port;
|
||||
this.p = p;
|
||||
Server = new SocketIOServer(new SocketIOServerOption(Port));
|
||||
Server.OnConnection((socket) => OnConnect(socket));
|
||||
Server.Start();
|
||||
Console.WriteLine($"Server started, binding to port {Port}, waiting for connection...");
|
||||
}
|
||||
|
||||
private void OnConnect(SocketIOSocket socket)
|
||||
{
|
||||
Console.WriteLine($"{socket.GetHashCode()} connected to the server");
|
||||
Sockets.Add(socket);
|
||||
socket.On(SocketIOEvent.DISCONNECT, () => OnDisconnect(socket));
|
||||
socket.On("Message", (Data) => p.OnMessageCallback(socket, Data));
|
||||
}
|
||||
|
||||
private void OnDisconnect(SocketIOSocket socket)
|
||||
{
|
||||
Sockets.Remove(socket);
|
||||
}
|
||||
|
||||
public bool SendMessage(SocketIOSocket socket)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
49
PolyChat/Package.appxmanifest
Normal file
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
IgnorableNamespaces="uap mp">
|
||||
|
||||
<Identity
|
||||
Name="ee2ef4f2-e61b-497a-8f0e-9fa7c90234b1"
|
||||
Publisher="CN=HPL2FE"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="ee2ef4f2-e61b-497a-8f0e-9fa7c90234b1" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>PolyChat</DisplayName>
|
||||
<PublisherDisplayName>HPL2FE</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="PolyChat.App">
|
||||
<uap:VisualElements
|
||||
DisplayName="PolyChat"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png"
|
||||
Description="PolyChat"
|
||||
BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
</Capabilities>
|
||||
</Package>
|
||||
190
PolyChat/PolyChat.csproj
Normal file
@@ -0,0 +1,190 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.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>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{23ACF793-F4C9-48C2-893C-7BD4A601EF40}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>PolyChat</RootNamespace>
|
||||
<AssemblyName>PolyChat</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
|
||||
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
|
||||
<OutputPath>bin\ARM64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\ChatMessage.cs" />
|
||||
<Compile Include="Models\ChatPartner.cs" />
|
||||
<Compile Include="Models\Client.cs" />
|
||||
<Compile Include="Models\ClientHandler.cs" />
|
||||
<Compile Include="Models\Exceptions\ConnectionFailedException.cs" />
|
||||
<Compile Include="Models\MSG.cs" />
|
||||
<Compile Include="Models\SendCode.cs" />
|
||||
<Compile Include="Models\Socket.cs" />
|
||||
<Compile Include="Controller.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Views\NewChatDialog.xaml.cs">
|
||||
<DependentUpon>NewChatDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\Default.rd.xml" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Views\NewChatDialog.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Json.Net">
|
||||
<Version>1.0.33</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.2.12</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="SocketIOSharp">
|
||||
<Version>2.0.3</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
29
PolyChat/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("PolyChat")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("BOSCH")]
|
||||
[assembly: AssemblyProduct("PolyChat")]
|
||||
[assembly: AssemblyCopyright("Copyright © BOSCH 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
31
PolyChat/Properties/Default.rd.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<!--
|
||||
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||
optimizer.
|
||||
|
||||
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
|
||||
|
||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
||||
|
||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||
|
||||
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||
<Namespace Name="DataClasses.ViewModels" Serialize="All" />
|
||||
-->
|
||||
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Application>
|
||||
<!--
|
||||
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||
the application package. The asterisks are not wildcards.
|
||||
-->
|
||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||
|
||||
|
||||
<!-- Add your application specific runtime directives here. -->
|
||||
|
||||
|
||||
</Application>
|
||||
</Directives>
|
||||
18
PolyChat/Views/NewChatDialog.xaml
Normal file
@@ -0,0 +1,18 @@
|
||||
<ContentDialog x:Class="PolyChat.Views.NewChatDialog"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="using:PolyChat.Views"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
x:Name="ContentDialog"
|
||||
Title="Connect to"
|
||||
PrimaryButtonClick="OnConnect"
|
||||
PrimaryButtonText="Connect"
|
||||
SecondaryButtonClick="OnClose"
|
||||
SecondaryButtonText="Cancel"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Grid>
|
||||
<TextBox x:Name="inputIP" PlaceholderText="192.168.1.1" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
</ContentDialog>
|
||||
35
PolyChat/Views/NewChatDialog.xaml.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using PolyChat.Models;
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
namespace PolyChat.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class NewChatDialog : ContentDialog
|
||||
{
|
||||
public NewChatDialog()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
public string getText()
|
||||
{
|
||||
return inputIP.Text;
|
||||
}
|
||||
|
||||
public void OnConnect(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
}
|
||||
|
||||
public void OnClose(ContentDialog sender, ContentDialogButtonClickEventArgs args)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||