The Group Chat (Vista, Windows 7) Sample Application demonstrates how to create a chat application based on the Peer-to-Peer Grouping and Identity Manager API. It shows a secure multiparty chat application into which you can authenticate people using a password or certificates.
Platforms supported
· Windows Vista (except Starter Edition)
· Windows 7
To Build:
· In a SDK command shell navigate to the directory containing this sample and run "nmake"; or
· Launch the .sln file in Visual Studio .NET
To Run:
· Type groupchat.exe (located in the Vista_DEBUG or WIN7_[ARCH]_DEBUG folder in the directory containing the sample)
· Just use the UI! When using the certificate model the following steps must be followed:
Creating a Peer Identity for each user
In the Group Chat application, a user can generate an identity by
selecting the "Create…" option on the "Identity" menu. The resulting
dialog box prompts the user for the friendly name (in this case, the "chat name")
that will be associated with the new identity.
Before a group can be created, an identity associated with the group creator
needs to be created.
Creating a group that will host the chat participants
When the group owner has an identity, a group is
created by selecting the "Create…" option on the "Group" menu. The resulting
dialog prompts the user for the identity of the group creator, as well as the
name of the group to be created. The newly created graph will be associated with the chosen identity.
Creating participants’ identity information files for invitations
Once the chat group has been created, chat members can solicit the group
owner for invitations to join the group. An invitation consists of an XML data
string derived from a unique identity (as created in step 1). An
invitation is thus exclusively bound to a particular identity. The group
owner uses the Peer-to-Peer Grouping API to generate an invitation from an
identity and then returns this invitation to the user requesting permission to
join the group.
Users that wish to join the chat group create user identities the same way that the group owner identity is created, using the "Create…" option on "Identity" menu. The "Identity" menu also allows the user to save this identity information to a file. This file is then sent out of band of the Peer-to-Peer infrastructure to the group owner, who creates the corresponding invitation.
Creating the invitations to join the group to chat
Once the group owner receives a file containing a user’s identity
information, they can create a file containing an invitation to join the group
using the "Create Invitation…" item on the "Group" menu. Selecting this option
opens the Create Invitation dialog and prompts the user to specify the
location of the identity information (.idt) file, as well as the destination of
the invitation information (.inv) file. The invitation file is then sent
out of band of the Peer-to-Peer infrastructure to the requesting individual.
It is important to note that invitations created with the Group Chat application demonstrate how to create invitations for the "Member" role. A group participant with a member role cannot issue invitations. Only participants with "Admin" credentials can create invitations.
Joining the Chat Group
In order to join the chat group, a user needs to have a predefined identity as
well as the invitation file that corresponds to that identity. If these
two requirements are satisfied, the "Join…" option on the "Group" menu can be
used to join the group. Selecting this option opens the Join Group dialog, which
requires the user to select his identity and location of the invitation
(.inv) file. Pressing the "OK" button initiates the join process. If this
is successful, the chat application will connect to the group and the chat user will be
online.
Whispering to other members
To carry on a private conversation with another member, simply double-click
that member in the 'Chat Members' list. The "Whisper" dialog will allow
the user to send a private message to the selected member.
Do not run groupchat.exe in an elevated command shell
The GroupChat sample uses the following ports: TCP port 3587 (used by p2p networking), UDP port 3540 (PNRP traffic: name registration), UDP port 1900 (SSDP protocol). Make sure that these ports are added to the advanced firewall inbound and outbound rules.
For example run the following in an elevated CMD shell to enable inbound TCP port number 3587
netsh advfirewall firewall add rule dir=in name="GroupChat SDK TCP 3587" localip=any remoteip=any localport=3587 remoteport=any protocol=tcp action=allow enable=yes
To test that the Peer Name Resolution Protocol works refer to the MSDN P2P Blog for the PNRP Debugging Guide Part 1