ChatBlade How To Documentation
How to Compile various ChatBlade Sample Programs

Related ChatBlade Classes and functions:  
    CBMFCTestClient.cpp
    CBSampleChatServer.java
    CBSampleChatServerApp.java
    CBMultiTasker.java
    Elvish.xml
    Filter.xml
    SlashCommands.xml

 
Summary:  
  Jump to section   Compile the Sample MFC Test Client application (CBMFCTestClient.cpp).  
  Jump to section Compile the Sample Java Chat Server.  
  Jump to section Edit the XML configuration files.  
  Jump to section Run the Sample Chat Server then the MFC Test Client.  
 

 
Details:  
 
Compile the Sample MFC Test Client application (CBMFCTestClient.cpp).  
     Under Visual Studio you can use the existing CBMFCClient.vcxproj file or alternatively you can create a New Project from Existing Files and perform the following steps:  
 
Set the location as C:\ChatBlade\Source\CBMFCTestClient if ChatBlade is installed on the C Drive.  
Add support for MFC.  
Define UNICODE and _UNICODE in the preprocessor definitions if UNICODE support is desired (UNICODE;_UNICODE).  
Add C:\ChatBlade\Include to the Include directories.  
Add CBMFCTestClient.cpp to the project as well as CBMFCTestClient.rc.  
Add in all the ChatBlade Source .cpp Files; CBAliasList.cpp, CBChatFilter.cpp, CBChatHandler.cpp, CBChatMessage.cpp, CBChatSampleNetworkClient.cpp, CBClientImplementation.cpp, CBCommandMap.cpp, CBData.cpp, CBEditFieldData.cpp, CBIgnoreList.cpp, CBLangaugeTable.cpp, CBNicknameList.cpp, CBSampleImplementation.cpp, CBSlashCommands.cpp, CBSpamFilter.cpp, CBTextWindowData.cpp, and CBUtils.cpp.  
Under older versions of Visual Studio, if compiling under UNICODE add in the Linker Entry Point of wWinMainCRTStartup (Under Linker/Advanced options).  
    Make sure the Linker Entry Point is removed if not compiling under UNICODE.  
Modern versions of Visual Studio only include the Unicode versions of MFC and the Multi-Byte Character Set MFC libraries are a separate download. To use the Unicode version, go to Project/Properties and under Configuration Properties/General change the Character Set drop down to be "Use Unicode Character Set".   
    Alternatively, if you wanted to compile not using Unicode you can download and install the MBCS libraries from here.   
Rebuild the entire Solution to make the Executables.  
 
CBMFCTestClient.exe needs 3 configuration .xml files to function properly.  Make sure the SlashCommands.xml, Elvish.xml, and Filter.xml files are located in the parent directory of the Executable.  
CBMFCTestClient.exe needs the Sample Java Chat Server active and running in order to function properly.  
Run the Sample Chat Server, then execute CBMFCTestClient.exe and see if it is functioning.  
 
Possible Issues:  
 
    If you get a Compilation error stating that "Building a MFC project for a non-Unicode Character Set is deprecated" then
        go to Project/Properties and under Configuration Properties/General change the Character Set drop down to be "Use Unicode Character Set".   
 
    If the Chat Server reports a Failure in ThreadedReceiver() for input string "?"  then
        make sure to set the Linker Entry Point of wWinMainCRTStartup when using UNICODE.  
 
    If you get Link errors that New and Delete are already defined then
        make sure to use MFC in a Shared DLL instead of MFC in a Static Library (under Project/Properties/Configuration Properties/General).  
 
    If you get a compilation error "Building an MFC Application with /MD[d] requires MFC shared DLL version" then
        make sure to use MFC in a Shared DLL instead of MFC in a Static Library (under Project/Properties/Configuration Properties/General).  
 
    If you want to use MFC in a Static Library, there is a bug in older versions of VC due to the order of linking in the MFC libraries and the standard libraries (for New and Delete, etc.  )
        To fix this in older versions of Visual Studio manually add in the correct MFC library to the project ((UAFXCWD.LIB, or UAFXCW.LIB for UNICODE Debug and UNICODE Release respectively) or (NAFXCWD.lib or NAFXCW.lib for non Unicode)).  
        Then go into the project settings and under the Input setting of the Linker section set Ignore Specific Library to be the one that you manually added to the project.  
 
    If CBMFCTestClient starts up but states that it is unable to load the three configuration files of SlashCommands.xml, Elvish.xml, and Filter.xml, then make sure they are in the Parent directory of the Executable.   
 
    If CBMFCTestClient starts up but immediately fails with an assert in CBitmapButton then make sure that the resource file (CBMFCTestClient.rc) has been added to the project.  
 
Compile the Sample Java Chat Server.  
ChatBlade ships with a Sample Chat Server written in Java (to support multiple platforms).  
     Download and install the latest Java Development Kit (JDK) from Sun.com; http://java.sun.com/javase/downloads/index.jsp
The Sample Chat Server is composed of 3 source files:  CBSampleChatServer.java, CBSampleChatServerApp.java, and CBMultiTasker.java.  
Compile these 3 files with the Java compiler into their .class components.  
    From a Dos box move to the ChatBlade\Source\CBSampleChatServer directory and execute the following line:  "C:\PROGRAM FILES\JAVA\JDK1.8.0_25\BIN\JAVAC" CBSampleChatServerApp.java CBSampleChatServer.java CBMultiTasker.java
    Alternatively run the Batch File to compile the Java Classes:  CompileSampleChatServer.bat.  (The batch file may need to be modified depending on the location of the Javac compiler).  
Note:  Depending on the version of the Java Development Kit installed these example locations of Javac and Java.exe may need to be changed.  
Compiling with Javac should result in 3 Class files; CBSampleChatServerApp.class, CBSampleChatServer.class, and CBMultiTasker.class.  
If there are errors in the Compilations then it is likely an older version of Java (before 1.5) is being used.  Either upgrade to the newest version, or edit the CBSampleChatServer.java file and remove the comments on the appropriate lines and comment out the lines that are conflicting with the older Java compiler.  
Sample Code:  
 
Edit the XML configuration files.  
     The Sample Chat Server makes use of an XML configuration file, ChatServer.xml.  
This configuration file sets the UDP ports used, up to 3 IPAddresses to receive the Chat Messages (for testing purposes), and whether or not to use UNICODE.  
If CBMFCTestClient.exe was compiled with UNICODE and _UNICODE defined then set <UnicodeEnabled> to 1.  If UNICODE is not defined then set it to 0.  
Sample Code:  
 
Run the Sample Chat Server then the MFC Test Client.  
     The MFC Test Client is designed to talk with the Sample Chat Server.  Therefore the Sample Chat Server needs to be running in order for Chat Messages to propagate back to the MFC Test Client.  
Activate the Sample Chat Server by starting up a DOS box and going to the ChatBlade\Source\CBSampleChatServer directory.  
Then type in "C:\PROGRAM FILES\JAVA\JDK1.8.0_25\BIN\JAVA" CBSampleChatServerApp     to start the Sample Chat Server.  
    Alternatively the Sample Chat Server can be invoked by executing the Batch File, RunCBSampleServer.bat.  
Once the Sample Chat Server is running, start up CBMFCTestClient.exe and type in some Chat.  
If all is working, then the Chat Message shall transmit to the Sample Chat Server which shall route them back to be displayed in the MFC Test Client.  
If the Sample Chat Server is running on a separate machine from the MFC Test Client, start up the Test Client and go to Options\SetServerIPAddress to set up the location of the Sample Chat Server.  
If no Chat Messages are getting displayed in the Client then there is a problem connecting the MFC Test Client with the Sample Chat Server.  Make sure the Sample Chat Server is running and both are configured correctly.  
Sample Code:  
 

 

Code Samples:  

Compiling the Sample Chat Server.  
     C:\ChatBlade\Source\CBSampleChatServer> "C:\PROGRAM FILES\JAVA\JDK1.8.0_25\BIN\JAVAC" CBSampleChatServerApp.java CBSampleChatServer.java CBMultiTasker.java
 
Configuring ChatServer.xml to support UNICODE.  
     <UnicodeEnabled>1</UnicodeEnabled>
 
Running the Sample Chat Server.  
     C:\ChatBlade\Source\CBSampleChatServer> "C:\PROGRAM FILES\JAVA\JDK1.8.0_25\BIN\JAVA" CBSampleChatServerApp
    
 
    
 
    

 

 

 

 

 

 
 
 
 
ChatBlade Copyright Flex Dolphynn