Introduction to PoshChat, A PowerShell Chat Client/Server

After a couple months of off and on work on this project, I can finally say that I have release my initial build of PoshChat, which is in version 0.9. This is a simple client/server chat room that allows any system to server as a chat server and allow multiple connections from different clients using the client script through port 15600. This is currently a hardcoded port, but there are plans to allow use of different ports for both the client and the server.

This article is more of an intro to using the application and does not go into the code behind the server and client. That will be talked about in a future article for each piece of code. However, I will say that I use runspaces created manually, timer objects with events that track each elapsed event, TCP listener, synced hashtables and synced queue objects to allow the relaying of messages between clients through the server.

With all that said, lets go ahead and step through using PoshChat.

Using PoshChat

First you need to download the ZIP file from the codeplex site.

image

Once the file is downloaded, go ahead and unzip the contents wherever you want.

Once, unzipped you can then decide where you want to run the server from using the Start-PoshChatServer.ps1 script to initialize the server listener. In this case, I will use my remote server, DC1 as the chat server.

image

Once started, the console will clear showing that the server has started.

image

From here, the server will begin listening for incoming connections from other clients. Now I will start up 4 clients on my laptop and connect to the server.

1..4 | ForEach {.\Start-PoshChatClient.ps1}

I type in my username and specify the server that I want to connect to and click connect.

image

After I do this with each client, I now have 4 connected clients to my remote server.

image

image

Something that I wanted to make sure was available and working with the clients in my initial release was to show the online clients connected to the server from the chat client.

image

Also, you can see when others join the chat room in the main message window.

image

Sending messages is as simple as typing in a message in the input box and clicking send:

image

Everyone connected to the server will receive the message.

image

You can also see sent messages from the server.

image

To leave the chat, simply close the chat window. There will be a disconnect button coming in a future release of this project.

When a user leaves the chat room, others will receive notification of this and the list of connected users will update accordingly.

image

 

Future Release Plans

This project is far from complete as I have many plans for updating this to include new features and bug fixes. Some notable updates have planned include:

  • Disconnect button
  • Minimize window
  • Encrypt/decrypt messages when sending
  • Code optimizations
  • Select ports for server listener and client connections
  • More to come as I think of them and what others would like to see

I welcome all bug findings and feature requests and ask that you direct those to the Issue Tracker on Codeplex found here.

As I mentioned at the beginning of the article, I will write 2 more articles detailing what I did with the client and server code to make this possible. I did learn some cool tricks while writing this and definitely want to share these with everyone else!

Enjoy!

This entry was posted in Modules, powershell, scripts and tagged , , , . Bookmark the permalink.

4 Responses to Introduction to PoshChat, A PowerShell Chat Client/Server

  1. Eric says:

    Hello, please, could you how can I have the accents when chating with french people?

  2. Pingback: PoshChat 1 of 2: Building a Chat Server Using PowerShell | Learn Powershell | Achieve More

  3. Chris Brown says:

    Fantasic. I can finally build that PowerShell botnet I always wanted! 😉

    Seriously though, I like the sound of this. I always wanted to build a chat client.

    • Boe Prox says:

      Thanks Chris! I always wanted to write a chat client/server using PowerShell and did learn a ton of cool things during this process. I’m hoping to have the other articles written by next weekend, time permitting.

Leave a Reply to Eric Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s