Example #1
0
/*******************************************************************************
* 注销会议室, 并且将在会议室中的参与者踢出. 该接口服务器做的是不负责任调用, 我们应该在调
* 用该接口一段时间后进行getMeetingInfo或者isMeetingRunning接口调用, 以对关闭操作进行
* 验证, 确保已经成功执行
* 返回: 调用成功返回true, 否则返回false
*******************************************************************************/
func (meetingRoom *MeetingRoom) End() bool {
	if "" == meetingRoom.MeetingID_ || "" == meetingRoom.ModeratorPW_ {
		log.Println("ERROR: PARAM ERROR.")
		return false
	}

	createParam := "meetingID=" + url.QueryEscape(meetingRoom.MeetingID_) +
		"&password="******"end", createParam, config.SALT)

	createResponse := command.HttpGet(config.BASE_URL + "end?" + createParam + "&checksum=" +
		checksum)

	if "ERROR" == createResponse {
		log.Println("ERROR: HTTP ERROR.")
		return false
	}

	responseXML := models.EndResponse{}
	err := xml.Unmarshal([]byte(createResponse), &responseXML)

	if nil != err {
		log.Println("XML PARSE ERROR: " + err.Error())
		return false
	}

	if "SUCCESS" == responseXML.ReturnCode {
		log.Println("END MEETING SUCCESS.")
		return true
	}

	return false
}
Example #2
0
/*******************************************************************************
* 获取会议室的详细信息, 并且刷新会议室实体中会议室详细信息的描述
* 返回: 会议室详细信息
*******************************************************************************/
func (meetingRoom *MeetingRoom) GetMeetingInfo() *models.GetMeetingInfoResponse {
	if "" == meetingRoom.MeetingID_ || "" == meetingRoom.ModeratorPW_ {
		log.Println("ERROR: PARAM ERROR.")
		return nil
	}

	createParam := "meetingID=" + url.QueryEscape(meetingRoom.MeetingID_) +
		"&password="******"getMeetingInfo", createParam, config.SALT)

	createResponse := command.HttpGet(config.BASE_URL + "getMeetingInfo?" + createParam +
		"&checksum=" + checksum)

	if "ERROR" == createResponse {
		log.Println("ERROR: HTTP ERROR.")
		return nil
	}

	err := xml.Unmarshal([]byte(createResponse), &meetingRoom.MeetingInfo)

	if nil != err {
		log.Println("XML PARSE ERROR: " + err.Error())
		return nil
	}

	if "SUCCESS" == meetingRoom.MeetingInfo.ReturnCode {
		log.Println("GET MEETING INFO SUCCESS.")
		return &meetingRoom.MeetingInfo
	}

	return nil
}
Example #3
0
/*******************************************************************************
* 检查当前会议室是否正常运行(开门). 当会议室中没有参与者的时候, 该接口调用将认为此会议室
* 未运行, 返回false
* 返回: true, 会议室运行正常; false, 会议室不存在
*******************************************************************************/
func (meetingRoom *MeetingRoom) IsMeetingRunning() bool {
	if "" == meetingRoom.MeetingID_ {
		log.Println("ERROR: PARAM ERROR.")
		return false
	}

	createParam := "meetingID=" + url.QueryEscape(meetingRoom.MeetingID_)
	checksum := command.GetChecksum("isMeetingRunning", createParam, config.SALT)

	createResponse := command.HttpGet(config.BASE_URL + "isMeetingRunning?" + createParam +
		"&checksum=" + checksum)

	if "ERROR" == createResponse {
		log.Println("ERROR: HTTP ERROR.")
		return false
	}

	responseXML := models.IsMeetingRunningResponse{}
	err := xml.Unmarshal([]byte(createResponse), &responseXML)

	if nil != err {
		log.Println("XML PARSE ERROR: " + err.Error())
		return false
	}

	if "SUCCESS" == responseXML.ReturnCode {
		log.Println("CALLED SUCCESS.")
		return responseXML.Running
	}

	return false
}
Example #4
0
/*******************************************************************************
* 根据参与者类的配置获得要加入的会议室的地址, 获取的地址可以直接进入到会议室当中
* 返回: 加入指定会议室的URL
*******************************************************************************/
func (participants *Participants) GetJoinURL() string {
	if "" == participants.FullName_ || "" == participants.MeetingID_ ||
		"" == participants.Password_ {
		return "ERROR: PARAM ERROR."
	}

	// 构造必填参数
	fullName := "fullName=" + url.QueryEscape(participants.FullName_)     // 用户名
	meetingID := "&meetingID=" + url.QueryEscape(participants.MeetingID_) // 试图加入的会议ID
	password := "******" + url.QueryEscape(participants.Password_)    // 会议室密码, 这里特指与会者密码, 如果传入管理员密码则以管理员身份进入

	var createTime string  // 会议室创建时间, 用来匹配MeetingID, 避免同一个参会者多次进入
	var userID string      // 标识用户身份的ID, 在调用GetMeetingInfo时将返回
	var configToken string // 有SetConfigXML调用返回的Token
	var avatarURL string   // 用户头像的URL, 当config.xml中displayAvatar为true时提供
	var redirect string    // 当HTML5不可用时, 是否重定向到Flash客户端
	var clientURL string   // 重定向URL

	if "" != participants.CreateTime {
		createTime = "&createTime=" + url.QueryEscape(participants.CreateTime)
	}

	if "" != participants.UserID {
		userID = "&userID=" + url.QueryEscape(participants.UserID)
	}

	if "" != participants.ConfigToken {
		configToken = "&configToken=" + url.QueryEscape(participants.ConfigToken)
	}

	if "" != participants.AvatarURL {
		avatarURL = "&avatarURL=" + url.QueryEscape(participants.AvatarURL)
	}

	if "" != participants.ClientURL {
		redirect = "&redirect=true"
		clientURL = "&clientURL=" + url.QueryEscape(participants.ClientURL)
	}

	// 合成请求参数
	joinParam := fullName + meetingID + password + createTime + userID +
		configToken + avatarURL + redirect + clientURL

	checksum := command.GetChecksum("join", joinParam, config.SALT)
	joinUrl := config.BASE_URL + "join?" + joinParam + "&checksum=" + checksum
	participants.JoinURL = joinUrl

	return joinUrl
}
Example #5
0
/*******************************************************************************
* 根据会议室的配置创建会议室, 将返回信息存储在CreateMeetingResponse属性中
* 返回: 创建成功返回会议室ID, 创建失败返回ERROR及失败内容
*******************************************************************************/
func (meetingRoom *MeetingRoom) CreateMeeting() string {
	// 检查必填字段
	if "" == meetingRoom.Name_ || "" == meetingRoom.MeetingID_ ||
		"" == meetingRoom.AttendeePW_ || "" == meetingRoom.ModeratorPW_ {
		log.Println("ERROR: PARAM ERROR.")
		return "ERROR: PARAM ERROR."
	}

	// 根据对象字段构造必填参数
	name := "name=" + url.QueryEscape(meetingRoom.Name_)                       // 会议名称
	meetingID := "&meetingID=" + url.QueryEscape(meetingRoom.MeetingID_)       // 会议ID
	attendeePW := "&attendeePW=" + url.QueryEscape(meetingRoom.AttendeePW_)    // 与会者密码
	moderatorPW := "&moderatorPW=" + url.QueryEscape(meetingRoom.ModeratorPW_) // 管理员密码

	var welcome string                 // 欢迎语
	var logoutURL string               // 退出后地址
	var record string                  // 是否可以录制
	var duration string                // 会议时长
	var moderatorOnlyMessage string    // 问候语
	var allowStartStopRecording string // 是否允许启动/停止录制
	var voiceBridge string             // 通过Web加入语音会议时的PIN码

	if "" != meetingRoom.Welcome {
		welcome = "&welcome=" + url.QueryEscape(meetingRoom.Welcome)
	}

	if "" != meetingRoom.LogoutURL {
		logoutURL = "&logoutURL=" + url.QueryEscape(meetingRoom.LogoutURL)
	}

	if "" != meetingRoom.Record {
		record = "&record=" + url.QueryEscape(meetingRoom.Record)
	}

	//-----------------------------------------------------------------------------
	// 这里可能有问题, 未做字段内容校验, 如果有错着重检查
	duration = "&duration=" + url.QueryEscape(strconv.Itoa(meetingRoom.Duration))

	allowStartStopRecording = "&allowStartStopRecording=" +
		url.QueryEscape(strconv.FormatBool(meetingRoom.AllowStartStopRecording))
	//-----------------------------------------------------------------------------

	if "" != meetingRoom.ModeratorOnlyMessage {
		moderatorOnlyMessage = "&moderatorOnlyMessage=" +
			url.QueryEscape(meetingRoom.ModeratorOnlyMessage)
	} else {
		moderatorOnlyMessage = "&moderatorOnlyMessage=" +
			url.QueryEscape("我是["+meetingRoom.Name_+"]大家好.")
	}

	if "" != meetingRoom.VoiceBridge {
		voiceBridge = "&voiceBridge=" + url.QueryEscape(meetingRoom.VoiceBridge)
	} else {
		// 如果VoiceBridge参数为空, 那么我们分配一个随机数给它
		rand.Seed(9999)
		nTemp := 70000 + rand.Intn(9999)
		voiceBridge = "&voiceBridge=" + url.QueryEscape(strconv.Itoa(nTemp))
	}

	// 合成请求的参数
	createParam := name + meetingID + attendeePW + moderatorPW + welcome +
		voiceBridge + logoutURL + record + duration + moderatorOnlyMessage +
		allowStartStopRecording

	checksum := command.GetChecksum("create", createParam, config.SALT)

	// 发出请求
	createResponse := command.HttpGet(config.BASE_URL + "create?" + createParam + "&checksum=" +
		checksum)

	if "ERROR" == createResponse {
		log.Println("ERROR: HTTP ERROR.")
		return "ERROR: HTTP ERROR."
	}

	// 解析返回的XML结果, 判断是否成功创建会议室
	err := xml.Unmarshal([]byte(createResponse),
		&meetingRoom.CreateMeetingResponse)

	if nil != err {
		log.Println("XML PARSE ERROR: " + err.Error())
		return "ERROR: XML PARSE ERROR."
	}

	if "SUCCESS" == meetingRoom.CreateMeetingResponse.Returncode {
		log.Println("SUCCESS CREATE MEETINGROOM. MEETING ID: " +
			meetingRoom.CreateMeetingResponse.MeetingID)
		return meetingRoom.CreateMeetingResponse.MeetingID
	} else {
		log.Println("CREATE MEETINGROOM FAILD: " + createResponse)
		return "FAILD"
	}

	return "ERROR: UNKONW."
}