GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cometdchat/README.md at master · poshjosh/cometdchat

Expand file tree

/

README.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
85 lines (73 loc) · 2.98 KB
/

README.md

Copy path

File metadata and controls

85 lines (73 loc) · 2.98 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

cometdchat

A Java library for integrating Cometd based chat functionality into a Java Web Application

Usage

This will add chat functionality to your existing java web application. You will be able to chat with any user who browses to your web site directly.

Setp 1. Clone/download this library and add it to your project.

Setp 2. Add the xml below to your web.xml

    <!-- Servlet to query chat members -->
    <servlet>
        <servlet-name>ChatMembers</servlet-name>
        <servlet-class>com.looseboxes.cometd.chat.web.ChatMembers</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>ChatMembers</servlet-name>
        <url-pattern>/chatMembers</url-pattern>
    </servlet-mapping>
    <!-- Servlet to query cometd chat messages -->
    <servlet>
        <servlet-name>messages</servlet-name>
        <servlet-class>com.looseboxes.cometd.chat.servlets.Messages</servlet-class>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>messages</servlet-name>
        <url-pattern>/chat/messages</url-pattern>
    </servlet-mapping>
    <!-- CometdChat WebApp Config -->
    <context-param>
        <param-name>cometdChatAppName</param-name>
        <param-value>[PUT A NAME HERE]</param-value>
    </context-param>
    <filter>
        <filter-name>continuation</filter-name>
        <filter-class>org.eclipse.jetty.continuation.ContinuationFilter</filter-class>
        <async-supported>true</async-supported>
    </filter>
    <filter-mapping>
        <filter-name>continuation</filter-name>
        <url-pattern>/cometd/*</url-pattern>
    </filter-mapping>
    <!-- Cometd Servlet -->
    <servlet>
        <servlet-name>cometd</servlet-name>
        <servlet-class>com.looseboxes.cometd.chat.servlets.CometdWithMessageConsumer</servlet-class>
        <async-supported>true</async-supported>
        <init-param>
            <param-name>transports</param-name>
            <param-value>org.cometd.websocket.server.WebSocketTransport</param-value>
        </init-param>
        <init-param>
            <param-name>services</param-name>
            <param-value>com.looseboxes.cometd.chat.ChatService</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>cometd</servlet-name>
        <url-pattern>/cometd/*</url-pattern>
    </servlet-mapping>

Setp 3. Add the code below to any ServletContextListener's contextInitialized(ServletContextEvent) method

public void contextInitialized(ServletContextEvent servletContextEvent) {

    final ServletContext servletContext = servletContextEvent.getServletContext();    

    final CometdChat cometdChat = new CometdChat(servletContext);
}

Setp 4. Add this to the head section of any jsp or jspf page you want chat to be available from

<%@taglib uri="/META-INF/tlds/cometdchat" prefix="cometdchat"%>
<cometdchat:joinChat loginUserDisplayName="me" windowBackground="navy"/>
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.