com.jwebmp.plugins.atmosphere.abstraction.AtmosphereAdapter Maven / Gradle / Ivy
/*
* Copyright (C) 2017 Marc Magon
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package com.jwebmp.plugins.atmosphere.abstraction;
import com.jwebmp.core.base.ajax.AjaxResponse;
import com.jwebmp.plugins.atmosphere.transport.AtmosphereWSReceiver;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereResourceEvent;
import java.util.Comparator;
/**
* Session container for atmosphere
*
* @author Marc Magon
* @since 19 Mar 2017
*/
public abstract class AtmosphereAdapter
implements Comparator
{
/**
* The sort order of the resources
*/
private int sortOrder = 100;
/*
* Constructs a new AtmosphereAdapter
*/
public AtmosphereAdapter()
{
//Nothing needed
}
@Override
public int compare(AtmosphereAdapter o1, AtmosphereAdapter o2)
{
return o1.getSortOrder()
.compareTo(o2.getSortOrder());
}
/**
* Returns the sort order of this adapter
*
* @return
*/
public Integer getSortOrder()
{
return sortOrder;
}
/**
* Sets the sort order of this adapter
*
* @param sortOrder
*/
public void setSortOrder(int sortOrder)
{
this.sortOrder = sortOrder;
}
/**
* Invoked when the connection as been fully established and suspended, e.g
* ready for receiving messages.
*
* @return
*/
@SuppressWarnings("unused")
public AjaxResponse onReady(AtmosphereResource r)
{
return new AjaxResponse();
}
/**
* Invoked when the client disconnect or when an unexpected closing of the
* underlying connection happens.
*
* @param event
*/
public void onDisconnect(AtmosphereResourceEvent event)
{
}
/**
* What happens on a message
*
* @param message
*
* @return
*/
public AjaxResponse onMessage(AtmosphereWSReceiver message)
{
if (message != null)
{
message.getData();
}
return new AjaxResponse();
}
/**
* When a connection is resumed after being suspended
*
* @param r
*
* @return
*/
public AjaxResponse onResume(AtmosphereResourceEvent r)
{
if (r != null)
{
r.getResource();
}
return new AjaxResponse();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy