PackageCn.andros230.netty;/** The Netty project * * The Netty project licenses this file to you under the Apache License, * versio N 2.0 (the "License"); You are not a use of this file except in compliance * with the License. Obtain a copy of the License at: * *http://www.apache.org/licenses/LICENSE-2.0* * Unless required by applicable or agreed to writing, software * Distributed under the License is distribute D on a "as is" BASIS, without * warranties or CONDITIONS of any KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */Importjava.awt.AWTException;ImportJava.awt.MouseInfo;ImportJava.awt.Point;ImportJava.awt.Robot;Importjava.awt.event.InputEvent;Importjava.awt.event.KeyEvent;ImportIo.netty.channel.ChannelHandlerContext;ImportIo.netty.channel.ChannelInboundHandlerAdapter; Public classObjectechoserverhandlerextendsChannelinboundhandleradapter {Private intMouseX; Private intMousey; PrivateRobot Robot; PublicObjectechoserverhandler ()throwsawtexception {robot=NewRobot (); } @Override Public voidexceptioncaught (Channelhandlercontext ctx, throwable cause) {cause.printstacktrace (); Ctx.close (); } @Override Public voidChannelread (Channelhandlercontext ctx, Object msg)throwsawtexception {Data Data=(Data) msg; //System.out.println (Data.getx () + "" +data.gety ()); if(Data.gettype (). Equals ("Down") { point point=mouseinfo.getpointerinfo (). GetLocation (); MouseX= (int) Point.getx (); Mousey= (int) point.gety (); } if(Data.gettype (). Equals ("Move") {robot.mousemove (MouseX+ (-data.getx ()), Mousey + (-data.gety ())); Robot.setautodelay (10); } if(Data.gettype (). Equals ("Up") {System.out.println (Click); Robot.mousepress (Inputevent.button1_mask); Robot.mouserelease (Inputevent.button1_mask); } if(Data.gettype (). Equals ("Long") {robot.mousepress (inputevent.button3_mask); Robot.mouserelease (Inputevent.button3_mask); } }}
Hard working workers