⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 J2ME实现得梭哈游戏联网程序
💻 JAVA
字号:

/**************************************************************
 * ************************************************************
 * 此项目是新框架“悠乐空间_棋牌”下的新项目:攀枝花麻将
 * 从项目工程的命名、具体游戏的包的命名都遵从公司规定的命名规则
 * 新框架下项目最大的特征就是在收发报文机制方面做了较大的调整
 * @date   :2008-11-10 Monday
 * @author :Welliam
 * ************************************************************
 **************************************************************/
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.rms.RecordStore;


public class Main extends MIDlet 
{
	
	static Main midletInstance;	
	static Display s_display;
	static Hall s_hall;
	private String rmsName = "IPTVRMS";
	private RecordStore recordStore;
	
	public Main() 
	{
		// TODO 自动生成构造函数存根
		midletInstance = this;
	}
	protected void destroyApp(boolean arg0)
	{// throws MIDletStateChangeException {
		// TODO 自动生成方法存根
		if (midletInstance != null)
			 midletInstance = null;
		notifyDestroyed();
	}
	protected void pauseApp() 
	{
		// TODO 自动生成方法存根

	}
	protected void startApp() throws MIDletStateChangeException 
	{
		// TODO 自动生成方法存根	
		GB2312CovertUTF.readUTF();
		Hall.minStartCondition = 1;
		Hall.Test =false;//给测试用true 给平台用false
		//需要用户名密码的用TRUE  需要令牌环的用false
		//Def.bDgg=false;
		System.out.println("Def.bDgg"+Def.bDgg+"Hall.Test"+Hall.Test);
		if(Def.bDgg)
		{
			Hall.accountID = 142;
			//Hall.accountID = 10006940;
			//Hall.accountID = 10006941;
			//Hall.accountID = 10006942;
//			Hall.accountID = 10006943;
//			Hall.accountID = 10006944;
//			Hall.accountID = 10006945;
			Hall.playerpsw = "96e79218965eb72c92a549dd5a330112";
			
//			Hall.server = new String("192.168.18.16");
//			Hall.port = 32323;
			
//			Hall.server = new String("192.168.0.179");
//			Hall.port = 2008;
			
//			Hall.server = new String("192.168.0.80");
//			Hall.port = 5123;
			//Hall.server = new String("118.123.242.9");
			Hall.server = new String("192.168.0.107");
			Hall.port = 188;
			//Hall.token="1541f0f50ae5290cf8a661e1d53375f889a104d3c39ce9ce";
			//System.out.println(Hall.Test+"debug"+Hall.token);
		}else
		{
			try{
				rmsOpen();
				byte[] tmp1=recordStore.getRecord(1);
				Hall.accountID  = Integer.parseInt((new String(tmp1)).trim());
				byte[] tmp2 =recordStore.getRecord(2);
				Hall.roomId  = Integer.parseInt((new String(tmp2)).trim());
				byte[] tmp3 =recordStore.getRecord(3);
				Hall.server = (new String(tmp3)).trim();
				byte[] tmp4 =recordStore.getRecord(4);
				Hall.port =  Integer.parseInt((new String(tmp4)).trim());
				byte[] tmp5 =recordStore.getRecord(5);
				Hall.playerpsw = (new String(tmp5)).trim();
				//System.out.println(Hall.Test+"try"+Hall.token);
			}
			catch(Exception e)
			{
				
				e.printStackTrace();
				/*Hall.server = getAppProperty("server");
				Hall.url	= getAppProperty("url");
				Hall.port = Integer.parseInt(getAppProperty("port"));
				Hall.roomId = Integer.parseInt(getAppProperty("roomid"));
				Hall.accountID = Integer.parseInt(getAppProperty("accountid"));	
				Hall.playerpsw = getAppProperty("roompsw");*/
				Hall.server = getAppProperty("server");
				Hall.url	= getAppProperty("url");
				
				Hall.port = Integer.parseInt(getAppProperty("port"));
				//Hall.server = new String("192.168.0.179");
				//Hall.port = 2008;
				System.out.println("Hall.server"+Hall.server+Hall.Test+"exceptiontoken"+Hall.token);
				if(Hall.Test)
				{
					Hall.accountID = Integer.parseInt(getAppProperty("accountid"));	
					Hall.playerpsw = getAppProperty("playerpsw");
					System.out.println("id"+Hall.accountID+"Hall.playerpsw"+Hall.playerpsw);
				}
				else
					{
					 // Hall.accountID = Integer.parseInt(getAppProperty("accountid"));	
					   //System.out.println("getAppProperty"+getAppProperty("accountid"));
					  // Hall.accountID=142;
					 //  Hall.server = new String("192.168.0.107");
					  // Hall.port = 188;
					    Hall.token = getAppProperty("token");
					    // Hall.playerpsw = "96e79218965eb72c92a549dd5a330112";
					  // System.out.println("Hall.accountIDis"+Hall.accountID+"Hall.token"+Hall.token);
					}
				
			}
		}
		
		if(s_hall==null)s_hall = new Hall(this);
	}
	
	 //跳转页面
    public void goToReturnURL()
    {
    	Runtime.getRuntime().gc();
    	try 
    	{
    		System.out.println("hall.url ========="+ Hall.url);
			 platformRequest(Hall.url);
		} 
    	catch (ConnectionNotFoundException e) 
		{
			e.printStackTrace();
		}
		//加下面这段是因为长虹的盒子会跳转不成功,没有反映,因此需要加这段来结束游戏
		try
		{
			destroyApp(true);
		}catch(Exception e)
		{
			System.out.println(e.toString());
		}
    }
////////////////////RMS////////////////////////////  
//  打开RecordStore
  	public void rmsOpen()throws Exception
  	{
  		try
  		{
  			recordStore=RecordStore.openRecordStore(this.rmsName,true);
  		}catch(Exception e)
  		{
//  			canvas.paintText("openRecordStore Failed!");
  			return;
  		}
  	}
//  关闭RecordStore
  	public void rmsClose()throws Exception
  	{
  		if(recordStore!=null)
  		{
  			try
  			{
  				recordStore.closeRecordStore();
  			}catch(Exception e)
  			{
  				
  			}
  		}
  	}
  	
//  列出所有存在的RecordStore
  	public void rmsListRecordStores()throws Exception
  	{
  		try{
  			if(RecordStore.listRecordStores()!=null)
  			{
  				for(int i=0;;i++)
  				{
  					if(RecordStore.listRecordStores()[i]!=null)
  					{
//  						canvas.paintText(RecordStore.listRecordStores()[i]);
  					}
  					else
  					{
  						break;
  					}
  						
  				}
  			}
  			else
  			{
  				
  			}
//  				canvas.paintText("RecordStore is empty!");
  		}catch(Exception e)
  		{
  			throw new Exception(this.rmsName+"::open::"+e);
  		}
  	}
  	
//  获取RecordStore
  	public RecordStore rmsGetRecordStore()
  	{
  		return this.recordStore;
  	}

//  获取RecordStore的名字
  	public String rmsGetRMSName()
  	{
  		return this.rmsName;
  	}
	
//	static Main midletInstance;
//	static Hall s_game;
//	static Display s_display;
//	private RecordStore recordStore;
//	private String rmsName = "IPTVRMS";
//	public static String returnurl = "";//加上这个参数--返回页面的地址
//	public Main() {
//		midletInstance = this;
//	}
//
//	protected void destroyApp(boolean arg0){// throws MIDletStateChangeException {
//		if (midletInstance != null)
//			 midletInstance = null;
//		notifyDestroyed();
//	}
//
//	protected void pauseApp() {
//		// TODO 响应外部中断	
//
//	}
//	
//	 //跳转页面
//    public void goToReturnURL(){
//    	try {
//			 platformRequest(returnurl);
//		} catch (ConnectionNotFoundException e) {
//			e.printStackTrace();
//		}
//		
//		
//		//加下面这段是因为长虹的盒子会跳转不成功,没有反映,因此需要加这段来结束游戏
//		try{
//			destroyApp(true);
//		}catch(Exception e){
//			System.out.println(e.toString());
//		}
//    }
//
//	protected void startApp() throws MIDletStateChangeException {	
//		GB2312CovertUTF.readUTF();
//		if(Def.bDgg)
//			returnurl = "http://60.190.228.110/sichuan/";
//		else
//			returnurl = getAppProperty("returnurl");//机顶盒需要从页面上获取返回页面的地址,游戏调用页面也会加上这个参数,参数名就用“returnurl”
//		if(Def.bDgg){			
//			
////			Hall.s_server = new String("60.190.228.61");
////			Hall.s_port = 8103;
//			
////			Hall.s_server = new String("172.16.4.42");
////			Hall.s_port = 8089;
//			//			==========================================================
//			/**外网:血战到底     viewXuedi            192.168.1.51      8151     温沛炼  201100403    麻将类**/
////			Hall.s_server = new String("192.168.0.163");//080602 AM 连汤汤电脑			
////			Hall.s_port = 8164;//080602 AM 连汤汤电脑
////			Hall.s_port = 8063;//080602 AM 连汤汤电脑
//			
//			//Hall.s_server = new String("192.168.1.126");//080528 PM
//			Hall.s_server = new String("192.168.0.171");//080528 PM
//			Hall.s_port = 8152;//080919 PM
//			
//			Hall.s_roomid = 201101403;//201100403;//080528 PM
//			//Hall.s_roomid = 201101401;//080528 PM
//			
//			Hall.s_acountid = 11101773;/*2008-4-23 AM*///welliam
////			Hall.s_acountid = 8059158;
////			Hall.s_acountid = 11101774;
////			Hall.s_acountid = 11101775;
////			Hall.s_acountid = 11100534;
//			
//			//Hall.s_acountid = 11101776;			
//			Hall.s_roompsw = "96e79218965eb72c92a549dd5a330112";
//
//		}else{
//			try{
//				rmsOpen();
//				byte[] tmp1=recordStore.getRecord(1);
//				Hall.s_acountid  = Integer.parseInt((new String(tmp1)).trim());
//				byte[] tmp2 =recordStore.getRecord(2);
//				Hall.s_roomid  = Integer.parseInt((new String(tmp2)).trim());
//				byte[] tmp3 =recordStore.getRecord(3);
//				Hall.s_server = (new String(tmp3)).trim();
//				byte[] tmp4 =recordStore.getRecord(4);
//				Hall.s_port =  Integer.parseInt((new String(tmp4)).trim());
//				byte[] tmp5 =recordStore.getRecord(5);
//				Hall.s_roompsw = (new String(tmp5)).trim();
//			}catch(Exception e){
//				e.printStackTrace();
//				Hall.s_server = getAppProperty("server");
//				Hall.s_port = Integer.parseInt(getAppProperty("port"));
//				Hall.s_roomid = Integer.parseInt(getAppProperty("roomid"));
//				Hall.s_acountid = Integer.parseInt(getAppProperty("accountid"));	
//				Hall.s_roompsw = getAppProperty("roompsw");
//			}
//		}
//		if (s_game == null)	{
//			s_game = new Hall(this);			
//		}
//		if(Def.bCon&&Def.bCMID){	
//			s_game._commu.connect();
//			s_game._commu.checkServer();
//		}
//	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -