-(int) SendCustomData:(NSData *)data repeatCout:(int)reaptCout;
public abstract int SendCustomData(byte[] data,int repeatCout);
public abstract int SendCustomData(byte[] customdata,int repeatCout);
パラメータ | タイプ | 意味 |
data | NSData * 、byte[] | 渡す情報 |
reaptCout | int | 繰返し回数です。-1を入力すると無限回繰返し送信となります |
-(IBAction)SendCustData:(UIButton*)sender {int ret = 0;NSString *typeString;switch (sender.tag) {case 1:ret = [[[ITMGContext GetInstance] GetRoom] SendCustomData:[NSData dataWithBytes:_shareRoomID.text.UTF8String length:_roomIdText.text.length] repeatCout:_shareOpenID.text.intValue];typeString = @"sendCustData";break;case 2:ret = [[[ITMGContext GetInstance] GetRoom] StopSendCustomData];typeString = @"recvCustData";break;default:break;}if(ret != 0) {UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"set fail" message:[NSString stringWithFormat:@"%@:errorcode :%d",typeString,ret] delegate:NULL cancelButtonTitle:@"OK" otherButtonTitles:nil];[alert show];}}
String strData = mEditData.getText().toString();String repeatCount = mEditRepeatCount.getText().toString();int nRet = ITMGContext.GetInstance(getActivity()).GetRoom().SendCustomData(strData.getBytes(), Integer.parseInt(repeatCount));
InputField SendCustom_Count_InputField = transform.Find("inroomPanel/imPanel/SendCustom_Count_InputField").GetComponent<InputField>();InputField SendCustom_Data_InputField = transform.Find("inroomPanel/imPanel/SendCustom_Data_InputField").GetComponent<InputField>();transform.Find("inroomPanel/imPanel/SendCustom_Btn").GetComponent<Button>().onClick.AddListener(delegate (){string data = SendCustom_Data_InputField.text;string str_count = SendCustom_Count_InputField.text;int count = 0;if (int.TryParse(str_count, out count)) {Debug.Log(data+ count.ToString());byte[] byteData = Encoding.Default.GetBytes(data);int ret = ITMGContext.GetInstance().GetRoom().SendCustomData(byteData, count);if(ret != 0) {ShowWarnning(string.Format("send customdata failed err:{0}",ret));}}});}
-(void)OnEvent:(ITMG_MAIN_EVENT_TYPE)eventType data:(NSDictionary *)data{NSString *log = [NSString stringWithFormat:@"OnEvent:%d,data:%@", (int)eventType, data];switch (eventType) {case ITMG_MAIN_EVENT_TYPE_CUSTOMDATA_UPDATE: {if (ITMG_CUSTOMDATA_AV_SUB_EVENT_UPDATE == ((NSNumber *)data[@"sub_type"]).intValue) {UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"customdata" message:[NSString stringWithFormat:@"内容:%@,from:%@ ",data[@"content"],data[@"senderid"]] delegate:NULL cancelButtonTitle:@"OK" otherButtonTitles:nil];[alert show];}}break;}}
if (ITMGContext.ITMG_MAIN_EVENT_TYPE.ITMG_MAIN_EVENT_TYPE_CUSTOMDATA_UPDATE == type) {int subtype = data.getIntExtra("sub_event",-1);if (subtype == 0) {String content = data.getStringExtra("content");String sender = data.getStringExtra("senderid");Toast.makeText(getActivity(), String.format("recv content =%s, from:%s", content,sender), Toast.LENGTH_SHORT).show();}
void OnEvent(int eventType,int subEventType,string data){Debug.Log (data);switch (eventType) {case (int)ITMG_MAIN_EVENT_TYPE.ITMG_MAIN_EVENT_TYPE_CUSTOMDATA_UPDATE:{if(subEventType == (int)ITMG_CUSTOMDATA_SUB_EVENT.ITMG_CUSTOMDATA_AV_SUB_EVENT_UPDATE) {_customData = JsonUtility.FromJson<CustomDataInfo>(data);ShowWarnning(string.Format("recve customdata {0} from {1}",_customData.content,_customData.senderid));}}break;}
-(int) StopSendCustomData;
public abstract int StopSendCustomData();
public abstract int StopSendCustomData();
この記事はお役に立ちましたか?