Forwarding mail to proper list...
Begin forwarded message:
> From: 杉山 尚彦 <p-sugiyama_at_i-asp.ne.jp>
> Date: July 17, 2009 4:57:06 AM GMT+02:00
> To: issues_at_grizzly.dev.java.net
> Subject: Please teach me how to write the Socket Program between
> FLEX to GrizzlyServlet
> Reply-To: issues_at_grizzly.dev.java.net
>
> Hi ALL
>
>
> I have problem. I cannot connect the UesrClient.
> UesrClientProgram is made with AdobeFlex.
>
> 1:I do not know how to pass the CometEngine useing the
> SelectorThreadHandler on ServerServlet.
> 2:at similar problem in ClientProgram, Please teach a way of writing
> in the FLEX for
> comeing true Socket.
>
> I write the ServerProgram, follow it.
> Please teach me how to write the Socket Program between FLEX to
> GrizzlyServlet.
>
>
> Thanks All
>
> Nao
>
>
>
> ■Servlet
> ---------------------------------------------------------------------------
> import java.io.BufferedReader;
> import java.io.IOException;
> import java.io.InputStreamReader;
> import java.net.URL;
> import java.util.Calendar;
>
> import javax.servlet.ServletConfig;
> import javax.servlet.ServletException;
> import javax.servlet.http.*;
>
> import com.sun.enterprise.web.connector.grizzly.comet.CometContext;
> import com.sun.enterprise.web.connector.grizzly.comet.CometEngine;
> import com.sun.grizzly.Controller;
> import com.sun.grizzly.http.SelectorThreadHandler;
> import com.sun.grizzly.TCPSelectorHandler;
>
>
> public class StreamingServlet extends HttpServlet {
>
> private static String cometContextPath;
>
> private static String lastTickTime;
>
> private static final String BR = "!";
>
> protected Controller controller;
>
> protected Selector selector;
>
> @Override
> public void init(ServletConfig config) throws ServletException {
> System.out.println("init");
>
> cometContextPath = config.getServletContext().getContextPath()+ "/
> streaming";
> CometContext context =
> CometEngine.getEngine().register(cometContextPath);
>
> lastTickTime =
> String.valueOf(Calendar.getInstance().getTimeInMillis());
>
> context.setExpirationDelay(60 * 1000);
> }
>
> @Override
> protected void doGet(HttpServletRequest request,
> HttpServletResponse response) throws ServletException,
> IOException {
>
> controller = new Controller();
> SelectorThreadHandler selectorHandler = new
> SelectorThreadHandler();
> selectorHandler.setSelector(selector);
> selectorHandler.setSelectorThread(this);
> selectorHandler.setPort(8000);
> selectorHandler.setInet(inet);
> selectorHandler.setLinger(linger);
> selectorHandler.setLogger(logger);
> selectorHandler.setReuseAddress(reuseAddress);
> selectorHandler.setSelectTimeout(selectorTimeout);
> selectorHandler.setServerTimeout(1000);
> selectorHandler.setSocketTimeout(keepAliveTimeoutInSeconds *
> 1000);
> selectorHandler.setSsBackLog(ssBackLog);
> selectorHandler.setTcpNoDelay(tcpNoDelay);
> controller.setSelectorHandler(selectorHandler);
>
>
>
>
> //CometHandlerを実装したクラス作成しをattachする。
> CometResponseHandler handler = new CometResponseHandler();
>
> handler.attach(response.getWriter());
> handler.attach(controller.getAttributes());
>
> //Comethandlerを追加することでこれより先notify()が
> 呼ばれるごとにonEventに処理を委託できる
> CometContext context =
> CometEngine.getEngine().getCometContext(cometContextPath);
> context.addCometHandler(handler);
>
> System.out.println("==== GET =====");
> context.notify("START");
> }
>
>
>
> }
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: issues-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: issues-help_at_grizzly.dev.java.net
>